Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Keep Package Running if Webclient has Timeout Expand / Collapse
Author
Message
Posted Wednesday, August 22, 2012 12:08 PM


SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Sunday, September 8, 2013 9:25 AM
Points: 96, Visits: 495
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
Post #1348626
Posted Wednesday, August 22, 2012 12:13 PM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: 2 days ago @ 1:42 PM
Points: 12,905, Visits: 32,157
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
Post #1348631
Posted Wednesday, August 22, 2012 12:24 PM


SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Sunday, September 8, 2013 9:25 AM
Points: 96, Visits: 495
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
Post #1348641
Posted Friday, August 24, 2012 7:09 PM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Yesterday @ 5:14 PM
Points: 7,125, Visits: 12,719
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
Post #1349987
Posted Monday, August 27, 2012 10:21 AM


SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Sunday, September 8, 2013 9:25 AM
Points: 96, Visits: 495
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
Post #1350474
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse