System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. System.Net.WebException: The operation has timed out error in SSIS Script Task

This is one of the error I got recently when I was running one SQL server Job. It was bit strange in my case.

Let me explain you the actual issue and what all I have checked before finding out the issue.

My SSIS job extracts excel from SSRS report and Zip it in a folder. So first thing I tried is, open the SSRS report. Interestingly it worked fine. So I open the report in visual studio to debug the issue and tried to open the report in preview mode. But that also worked without any issue.

So only thing is to run the report in debug mode.I ran the job and I got the exact “The operation has timed out error”. So What I did was increased the execute SQL task time out from 600 to some higher number but that also didn't worked.

Finally I realized that issue is while calling the webservice to extract the SSRS report. Which means it is timing out from the webservice. So just before calling the SSRS report I have increased the timeout value.

Now lets see the code. I am explaining this with the sample code from MSDN.

I am explaining this with the sample code from MSDN

Below was the actual code I was using when I was getting the error.

        mySSRS_ExecService.ExecutionHeaderValue = execHeader
        execInfo = mySSRS_ExecService.LoadReport(reportPath, historyID)

        'Pass Parameters to Report
        SessionId = mySSRS_ExecService.ExecutionHeaderValue.ExecutionID
        ' Console.WriteLine("SessionID: {0}", mySSRS_ExecService.ExecutionHeaderValue.ExecutionID)

        Try
            result = mySSRS_ExecService.Render(format, devInfo, extension, _
               encoding, mimeType, warnings, streamIDs)

            execInfo = mySSRS_ExecService.GetExecutionInfo()

            'Console.WriteLine("Execution date and time: {0}", execInfo.ExecutionDateTime)

        Catch e As System.Web.Services.Protocols.SoapException
            MsgBox("Error in web services")
        End Try


After modification by increasing the time out portion of the code will be like below,

        mySSRS_ExecService.ExecutionHeaderValue = execHeader
        mySSRS_ExecService.Timeout = 60000

        execInfo = mySSRS_ExecService.LoadReport(reportPath, historyID)

        'Pass Parameters to Report
        SessionId = mySSRS_ExecService.ExecutionHeaderValue.ExecutionID
        ' Console.WriteLine("SessionID: {0}", mySSRS_ExecService.ExecutionHeaderValue.ExecutionID)

        Try
            result = mySSRS_ExecService.Render(format, devInfo, extension, _
               encoding, mimeType, warnings, streamIDs)

            execInfo = mySSRS_ExecService.GetExecutionInfo()

            'Console.WriteLine("Execution date and time: {0}", execInfo.ExecutionDateTime)

        Catch e As System.Web.Services.Protocols.SoapException
            MsgBox("Error in web services")
        End Try
 

You can see from the above code that I have added an extra line

rsRepExeService.Timeout=6000;

This line will resolve this issue.

For complete code sample for ReportExecutionService.Render Method please refer MSDN

No Comments