简体   繁体   中英

Timeout problem using WCF or Reporting Services with AlanJuden MvcReportViewer in ASP .net core 2.1

There are 2 projects within the MVC solution. A web app and a report app. Reports are on demand from the web app. Web app runs fine with the inclusion of a timeout in the reporting controller. (_context.Database.SetCommandTimeout(300);).

If I run any of the reports or a WCF job I get the following errors, BUT if I run them immediately again they run ok. If I wait till the next day I get the same results.

Seems to be a common problem related to Reporting Services but I have run out of ideas.

Reporting Error: AggregateException: One or more errors occurred. (The request channel timed out attempting to send after 00:01:00. Increase the timeout value passed to the call to Request or increase the SendTimeout value on the Binding. The time allotted to this operation may have been a portion of a longer timeout.)

System.Threading.Tasks.Task.GetResultCore(bool waitCompletionNotification)

TimeoutException: The request channel timed out attempting to send after 00:01:00. Increase the timeout value passed to the call to Request or increase the SendTimeout value on the Binding. The time allotted to this operation may have been a portion of a longer timeout.

System.Runtime.AsyncResult.End(IAsyncResult result) in AsyncResult.cs, line 354.

WCF Error: TimeoutException: The HTTP request to 'http://keeper/ReportServer/ReportExecution2005.asmx' has exceeded the allotted timeout of 00:01:00. The time allotted to this operation may have been a portion of a longer timeout.

System.ServiceModel.Channels.HttpChannelFactory+HttpClientRequestChannel+HttpClientChannelAsyncRequest.SendRequestAsync(Message message, TimeoutHelper timeoutHelper) in HttpChannelFactory.cs, line 1048

TimeoutException: The request channel timed out attempting to send after 00:01:00. Increase the timeout value passed to the call to Request or increase the SendTimeout value on the Binding. The time allotted to this operation may have been a portion of a longer timeout.

System.Runtime.AsyncResult.End(IAsyncResult result) in AsyncResult.cs, line 354.

Have added a web.config file:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <location path="." inheritInChildApplications="false">
    <system.webServer>
      <handlers>
        <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
      </handlers>
      <aspNetCore requestTimeout="00:30:00" processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" />
    </system.webServer>
  </location>
  <system.serviceModel>
    <bindings>
      <wsHttpBinding>
        <binding openTimeout="00:10:00"
                 closeTimeout="00:10:00"
                 sendTimeout="00:10:00"
                 receiveTimeout="00:10:00"
                 maxBufferPoolSize="2147483647" 
                 maxReceivedMessageSize="2147483647">
        </binding>
      </wsHttpBinding>
      <basicHttpBinding>
        <binding openTimeout="00:10:00"
                 closeTimeout="00:10:00"
                 receiveTimeout="00:10:00"
                 sendTimeout="00:10:00"
                 maxBufferPoolSize="2147483647"
                 maxReceivedMessageSize="2147483647"
                 maxBufferSize="2147483647">
        </binding>
      </basicHttpBinding>
    </bindings>
  </system.serviceModel>
</configuration>

The requestTimeout="00:30:00" stopped the WCF job falling over so now either doesn't start or runs to completion. Nothing else in the web.config seemed to affect the results.

Have also looked at C:/Program Files/Microsoft SQL Server Reporting Services/SSRS/ReportServer/rsreportserver.config file but cant see any time outs which might relate to the 00:01:00 problem.

4/12/2020 Have changed the web.config file to:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  
  <location path="." inheritInChildApplications="false">
    
    <system.webServer>
      <handlers>
        <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
      </handlers>
      <aspNetCore startupTimeLimit="600" shutdownTimeLimit="600" requestTimeout="00:30:00" processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" />
    </system.webServer>
  
    <system.serviceModel>
      
      <bindings>
        <basicHttpBinding>
          <binding name="ServiceReference1"
                   openTimeout="00:10:00"
                   closeTimeout="00:10:00"
                   receiveTimeout="00:10:00"
                   sendTimeout="00:10:00"
                   maxBufferPoolSize="2147483647"
                   maxReceivedMessageSize="2147483647"
                   maxBufferSize="2147483647">
          </binding>
        </basicHttpBinding>
      </bindings>

      <services>
        <service name="ServiceReference1">
          <endpoint address="http://Keeper/ReportServer/ReportExecution2005.asmx"
                    binding="basicHttpBinding"
                    bindingConfiguration="ServiceReference1"
                    contract=""/>
        </service>
      </services>
      
    </system.serviceModel>
    
  </location> 
  
</configuration>
enter code here

Latest web.config 6/12/2020

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <location path="." inheritInChildApplications="false">
    <system.webServer>
      <handlers>
        <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
      </handlers>
      <aspNetCore requestTimeout="00:30:00" processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" />
    </system.webServer>
  </location> 
</configuration>

In your configuration file, I don't see your endpoint, and the timeout attribute of binding is not applied to the endpoint. From the error report, it seems to be the problem of the timeout attribute.

For different timeout attributes, the most important is sendTimeout, which represents the time the client waits for a response from the WCF service.

OpenTimeout is the time you are willing to wait when opening a connection with the WCF service.

Similarly, closeTimeout is the time to wait before closing the connection (putting the client proxy) before waiting for an exception to be thrown.

ReceiveTimeout is the time that will be given to the client to receive and process the response from the server.

You can try to increase the timeout property and apply it to the endpoint.

For how to configure the endpoint in wcf, you can view this link: Configuring Services Using Configuration Files

As stated in comments, the RecycleTime in the rsreportserver.config file triggers a restart of the service SQL Server Reporting Services. Every time this happens there is an initialisation of Reporting Services required and this is triggered by the first report run after that event. This initialisation takes around 2 mins and (for me) results in a 1 min Timeout Error as reported earlier.

Still have no idea where this timeout comes from but here is the workaround thanks to Pavel and https://pawlowski.cz/2011/07/31/solving-issue-long-starting-report-ssrs-2008/

Basically this means: set the RecycleTime to 1500 (25 hrs), create a scheduled task to to run daily each morning which triggers a Powershell script to restart Reporting Services and then access the Reporting Services folder to initialise it. Note: I only have 1 Reporting Services for both localhost and production. If you have 2 you may need 2 jobs.

Pavel's commands for a Powershell script:

  1. Stop-Service "SQL Server Reporting Services (MSSQLSERVER)"
  2. Start-Service "SQL Server Reporting Services (MSSQLSERVER)"
  3. $wc = New-Object system.net.webClient
  4. $cred = [System.Net.CredentialCache]::DefaultNetworkCredentials
  5. $wc.Credentials = $cred
  6. $src = $wc.DownloadString("http://localhost/Reports/Pages/Folder.aspx")

I have used the following and included it in my solution to keep it all together:

  1. echo "Restarting SQL Server Reporting Services"
  2. Restart-Service "SQL Server Reporting Services"
  3. Start-Sleep -s 30
  4. echo "SQL Server Reporting Services available"
  5. $wc = New-Object system.net.webClient
  6. $cred = [System.Net.CredentialCache]::DefaultNetworkCredentials
  7. $wc.Credentials = $cred
  8. echo "Reporting Services Initialisation Starting"
  9. $src = $wc.DownloadString("http://keeper/ReportServer/Reports")
  10. echo "Reporting Services Initialisation Finished"
  11. Start-Sleep -s 30
  12. echo "Startup Finished"

This takes about 3 mins to run. I have noticed that Reporting Services takes about 15 secs to become available after a restart so that is why I have a sleep at step 3. Step 9. I am fairly sure that 'localhost' will work the same as your server name ('keeper' in my case). You only need the folder, not an actual report. Step 11 is just in case initialisation has not quite finished. At 2 am I dont care about a few extra minutes. The echos are for testing.

I have used Task Scheduler with the following settings: General; Name SSRS_Startup Triggers: Daily 2am Enabled Actions: Start a Program C:\\Windows\\System32\\WindowsPowerShell\\V1.0\\powershell.exe -ExecutionPolicy Bypass -file "SSRS_Startup.ps1" Settings: Allow task to be run on demand

Have detailed these as they are important, particularly Actions.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM