简体   繁体   English

在 ASP .net core 2.1 中使用 WCF 或 Reporting Services 和 AlanJuden MvcReportViewer 出现超时问题

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

There are 2 projects within the MVC solution. MVC 解决方案中有 2 个项目。 A web app and a report app.一个网络应用程序和一个报告应用程序。 Reports are on demand from the web app. Web 应用程序按需提供报告。 Web app runs fine with the inclusion of a timeout in the reporting controller. Web 应用程序运行良好,在报告控制器中包含超时。 (_context.Database.SetCommandTimeout(300);). (_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.如果我运行任何报告或 WCF 作业,我会收到以下错误,但如果我立即再次运行它们,它们运行正常。 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 Services 相关的常见问题,但我已经没有想法了。

Reporting Error: AggregateException: One or more errors occurred.报告错误:AggregateException:发生一个或多个错误。 (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.) (请求通道在 00:01:00 之后尝试发送超时。增加传递给 Request 调用的超时值或增加 Binding 上的 SendTimeout 值。分配给此操作的时间可能是较长超时的一部分.)

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

TimeoutException: The request channel timed out attempting to send after 00:01:00. TimeoutException:请求通道在 00:01:00 之后尝试发送超时。 Increase the timeout value passed to the call to Request or increase the SendTimeout value on the Binding.增加传递给 Request 调用的超时值或增加 Binding 上的 SendTimeout 值。 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. System.Runtime.AsyncResult.End(IAsyncResult result) in AsyncResult.cs,第 354 行。

WCF Error: TimeoutException: The HTTP request to 'http://keeper/ReportServer/ReportExecution2005.asmx' has exceeded the allotted timeout of 00:01:00. WCF 错误:TimeoutException:对“http://keeper/ReportServer/ReportExecution2005.asmx”的 HTTP 请求已超过分配的超时 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 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. TimeoutException:请求通道在 00:01:00 之后尝试发送超时。 Increase the timeout value passed to the call to Request or increase the SendTimeout value on the Binding.增加传递给 Request 调用的超时值或增加 Binding 上的 SendTimeout 值。 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. System.Runtime.AsyncResult.End(IAsyncResult result) in AsyncResult.cs,第 354 行。

Have added a web.config file:添加了一个 web.config 文件:

<?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. requestTimeout="00:30:00" 停止了 WCF 作业失败,因此现在要么不启动,要么运行完成。 Nothing else in the web.config seemed to affect the results. web.config 中的任何其他内容似乎都不会影响结果。

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.还查看了 C:/Program Files/Microsoft SQL Server Reporting Services/SSRS/ReportServer/rsreportserver.config 文件,但看不到任何可能与 00:01:00 问题相关的超时。

4/12/2020 Have changed the web.config file to: 4/12/2020 已将 web.config 文件更改为:

<?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.从错误报告来看,似乎是timeout属性的问题。

For different timeout attributes, the most important is sendTimeout, which represents the time the client waits for a response from the WCF service.对于不同的超时属性,最重要的是sendTimeout,它表示客户端等待WCF服务响应的时间。

OpenTimeout is the time you are willing to wait when opening a connection with the WCF service. OpenTimeout 是您在打开与 WCF 服务的连接时愿意等待的时间。

Similarly, closeTimeout is the time to wait before closing the connection (putting the client proxy) before waiting for an exception to be thrown.同样,closeTimeout 是在等待抛出异常之前关闭连接(放置客户端代理)之前等待的时间。

ReceiveTimeout is the time that will be given to the client to receive and process the response from the server. ReceiveTimeout 是将提供给客户端以接收和处理来自服务器的响应的时间。

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关于如何在wcf中配置端点,可以查看这个链接: 使用配置文件配置服务

As stated in comments, the RecycleTime in the rsreportserver.config file triggers a restart of the service SQL Server Reporting Services.如评论中所述,rsreportserver.config 文件中的 RecycleTime 会触发 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.每次发生这种情况时,都需要对 Reporting Services 进行初始化,这是由该事件后运行的第一个报告触发的。 This initialisation takes around 2 mins and (for me) results in a 1 min Timeout Error as reported earlier.此初始化需要大约 2 分钟,并且(对我而言)导致 1 分钟超时错误,如前所述。

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/仍然不知道这个超时来自哪里,但这里是 Pavel 和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.基本上这意味着:将 RecycleTime 设置为 1500(25 小时),创建一个计划任务,每天早上运行,触发 Powershell 脚本重新启动 Reporting Services,然后访问 Reporting Services 文件夹以对其进行初始化。 Note: I only have 1 Reporting Services for both localhost and production.注意:我只有 1 个用于本地主机和生产的 Reporting Services。 If you have 2 you may need 2 jobs.如果您有 2 个,则可能需要 2 个工作。

Pavel's commands for a Powershell script: Pavel 的 Powershell 脚本命令:

  1. Stop-Service "SQL Server Reporting Services (MSSQLSERVER)"停止服务“SQL Server 报告服务 (MSSQLSERVER)”
  2. Start-Service "SQL Server Reporting Services (MSSQLSERVER)"启动服务“SQL Server Reporting Services (MSSQLSERVER)”
  3. $wc = New-Object system.net.webClient $wc = 新对象 system.net.webClient
  4. $cred = [System.Net.CredentialCache]::DefaultNetworkCredentials $cred = [System.Net.CredentialCache]::DefaultNetworkCredentials
  5. $wc.Credentials = $cred $wc.Credentials = $cred
  6. $src = $wc.DownloadString("http://localhost/Reports/Pages/Folder.aspx") $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" echo "重新启动 SQL Server Reporting Services"
  2. Restart-Service "SQL Server Reporting Services"重新启动服务“SQL Server 报告服务”
  3. Start-Sleep -s 30开始睡眠 -s 30
  4. echo "SQL Server Reporting Services available" echo "SQL Server Reporting Services 可用"
  5. $wc = New-Object system.net.webClient $wc = 新对象 system.net.webClient
  6. $cred = [System.Net.CredentialCache]::DefaultNetworkCredentials $cred = [System.Net.CredentialCache]::DefaultNetworkCredentials
  7. $wc.Credentials = $cred $wc.Credentials = $cred
  8. echo "Reporting Services Initialisation Starting" echo "报表服务初始化启动"
  9. $src = $wc.DownloadString("http://keeper/ReportServer/Reports") $src = $wc.DownloadString("http://keeper/ReportServer/Reports")
  10. echo "Reporting Services Initialisation Finished" echo "报表服务初始化完成"
  11. Start-Sleep -s 30开始睡眠 -s 30
  12. echo "Startup Finished" echo "启动完成"

This takes about 3 mins to run.这大约需要 3 分钟才能运行。 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).我注意到 Reporting Services 需要大约 15 秒才能在重新启动后可用,这就是我在第 3 步睡眠的原因。第 9 步。我相当确定“localhost”将与您的服务器名称(“keeper” ' 在我的情况下)。 You only need the folder, not an actual report.您只需要文件夹,而不是实际的报告。 Step 11 is just in case initialisation has not quite finished.步骤 11 以防万一初始化还没有完全完成。 At 2 am I dont care about a few extra minutes.凌晨 2 点,我不在乎多花几分钟。 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名称 SSRS_Startup 触发器:每天凌晨 2 点启用操作:启动程序 C:\\Windows\\System32\\WindowsPowerShell\\V1.0\\powershell.exe -ExecutionPolicy Bypass -file "SSRS_Startup.ps1" 设置:允许任务按需运行

Have detailed these as they are important, particularly Actions.详细说明这些,因为它们很重要,尤其是操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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