download issue when Background Intelligent Transfer Service (BITS) gets restart in between. RRS feed

  • Question

  • I am trying to implement Background Intelligent Transfer Service(BITS) scenario, where it downloads file from IIS server. I have implemented call back "IBackgroundCopyCallback" as well. Its working fine if there is no system failure (like system shutdown, network issue, BITS service availability).
    implementation is based on Windows event base, where application has to wait for get signal by call back "CBackgroundCopyCallback::JobTransferred()" function, where it also call complete() function or another call back "CBackgroundCopyCallback::JobError()".
    if BITS is downloading big size file and BITS service gets stop in between, then call back JobTransferred() is not getting called, as result complete() also not getting called, so file remains as tmp file.
    (temp file is not renamed (available) till IBackgroundCopyJob::Complete() function is not getting called.)
    I also verified job state by printing them in call back "CBackgroundCopyCallback::JobModification()" method where last captured state is 'BG_JOB_STATE_TRANSFERRING'.
    Also verified job on cmd prompt by cmd "bitsadmin /list" multiple times, where job state changed from 'TRANSFERRING' to 'TRANSFERRED'.
    at last tmp file is same as remote file in size, application also remains in waiting state as it’s waiting for getting signaled by call back.
    1.) how can we handle this scenario? does BITS provide some kind of API to handle this.
    2.) in similar way if system get restarts in between then what is feasible way to complete that job? (as in this case application will also get terminated.)
    Monday, May 5, 2014 12:52 PM

All replies

  • Hi Nky,

    BITS provides client error handling and server error handling. BITS returns values and we can know the state of BITS process. See details from

    Handling errors:

    Handling server application errors:


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, May 6, 2014 5:34 AM
  • in 1st scenario, where BITS service gets stop and start, job was not in error state. as per in BITS working scenario if file transfer completed successfully then job state will be turned to TRANSFERRED and registered call-back interface method "JobTransferred()" should be called by BITS, or "JobError()" in case of failure.

    I have call SetNotifyFlags(BG_NOTIFY_JOB_TRANSFERRED | BG_NOTIFY_JOB_ERROR | BG_NOTIFY_JOB_MODIFICATION ) for mentioned 3 flags.
    for error state confirmation, I checked cmd "bitsadmin /list" multiple time where state changed as below:
    'TRANSFERRING' (when BITS service is already started and file transfer started) to
    'CONNECTING' (when BITS service is stopped) to
    'TRANSFERRING' (when BITS service is started again) to
    'TRANSFERRED' (when local file size is same as remote file has).
    It seems that job was never in error state during BITS service stop-start.

    here issue is that call-back method is not getting called if I go for stop and start BITS service.
    Tuesday, May 6, 2014 7:29 AM