|
|
|
SSC Journeyman
      
Group: General Forum Members
Last Login: 2 days ago @ 4:14 PM
Points: 91,
Visits: 472
|
|
Can someone here tell me how I can handle Webclient timeouts? I have a package downloading approximately 300 zipped files and it got hung up on one download. It just stopped running due to a timeout. I'm not sure how the package can proceed when a timeout occurs.
Regards: Mordred Keep on Coding in the Free World
|
|
|
|
|
SSChampion
        
Group: General Forum Members
Last Login: Yesterday @ 1:11 PM
Points: 11,605,
Visits: 27,645
|
|
i think what you want is instead of the web client, say executing a stored procedure that does a bunch of work, you want to have the web page activiate a service broker you would create;
the web page would get it's answer instantly that the service broekr was triggered, but the long process would be tripped by the broker, and would not worry about the web page timing out.
the service broker would execute the procedure or other process, and that's what we are after, right?
if you give a little more detials, i'm sure we could come up with a sample script for creating the broker and triggering the script? job? procedure?
Lowell
--There is no spoon, and there's no default ORDER BY in sql server either. Actually, Common Sense is so rare, it should be considered a Superpower. --my son
|
|
|
|
|
SSC Journeyman
      
Group: General Forum Members
Last Login: 2 days ago @ 4:14 PM
Points: 91,
Visits: 472
|
|
I'm a Service Broker virgin and just did some quick reading about it and will need to study up about it. I'm not really sure about what more details you would require but basically:
If there is a timeout, (perhaps) queue the missed download and try it again after all the other downloads are complete. My code that I am running looks like:Try ' Logging start of download Dim fireAgain As Boolean = True Dts.Events.FireInformation(0, "Download File", "Start downloading " + Dts.Variables("User::httpConnection").Value.ToString(), String.Empty, 0, fireAgain) ' Create a webclient to download a file Dim mySSISWebClient As WebClient = New WebClient() Dim pt As String pt = Dts.Variables("User::fileName").Value.ToString + ".zip" ' Download file and use the Flat File Connectionstring (D:\SourceFiles\Products.csv) ' to save the file (and replace the existing file) mySSISWebClient.DownloadFile(Dts.Variables("User::httpConnection").Value.ToString, "\\EWPG-SERVICE-60\FA-BUSANALYEC\EconomicDBTemp\DownloadedCSVs\" + Dts.Variables("User::fileName").Value.ToString + ".zip") Dts.Variables("User::FullPathTitle").Value = Dts.Variables("User::SaveFile").Value.ToString + pt Dts.Variables("User::FileNameDel").Value = Dts.Variables("User::fileName").Value.ToString ' Logging end of download Dts.Events.FireInformation(0, "Download File", "Finished downloading " + Dts.Variables("User::SaveFile").Value.ToString(), String.Empty, 0, fireAgain) ' Quit Script Task succesful Dts.TaskResult = ScriptResults.Success Catch ex As Exception ' Logging why download failed Dts.Events.FireError(0, "Download File", "Download failed: " + ex.Message, String.Empty, 0)
' Quit Script Task unsuccesful Dts.TaskResult = ScriptResults.Failure End Try Please let me know what I am missing regarding more information and I will gladly provide it. Thanks a bunch!
Regards: Mordred Keep on Coding in the Free World
|
|
|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Today @ 7:33 AM
Points: 6,696,
Visits: 11,713
|
|
If you want the package to keep going then you cannot fail the Task. I looked up the exceptions that can be thrown by the DownloadFile method and you'll likely get a WebException. I would add a second catch block that traps for WebException. If you can recreate the error then capture the error message. If the message is standard then you can check for it in your new catch block, and then retry the download if it was in fact a timeout.
Pseudocode:
Try Try Call download file method Set Task result to Success Catch WebException If error message indicates timeout Call download file method again Set Task result to Success Else rethrow error End Try Catch Set Task result to Failed End Try
Edit: adjust Try indentation
__________________________________________________________________________________________________ There are no special teachers of virtue, because virtue is taught by the whole community. --Plato
Believe you can and you're halfway there. --Theodore Roosevelt
Everything Should Be Made as Simple as Possible, But Not Simpler --Albert Einstein
The significant problems we face cannot be solved at the same level of thinking we were at when we created them. --Albert Einstein
1 apple is not exactly 1/8 of 8 apples. Because there are no absolutely identical apples. --Giordy
|
|
|
|
|
SSC Journeyman
      
Group: General Forum Members
Last Login: 2 days ago @ 4:14 PM
Points: 91,
Visits: 472
|
|
Thanks opc.three, I've nested another try catch statement that catches the time out and so far it I haven't had any problems. However, the process is a long one and because of colleague interruptions and meetings I haven't run straight through the process without manually stopping it. When (if) all have downloaded properly I will post about the success (or failure).
Thanks again!
Regards: Mordred Keep on Coding in the Free World
|
|
|
|