What 130 second timeout is killing my WCF streaming service call?

前端 未结 5 834
一向
一向 2020-12-08 16:22

Just recently I started to investigate a tricky problem with WCF streaming in which a CommunicationException is produced if the client waits for any longer than 130 seconds

相关标签:
5条回答
  • 2020-12-08 16:56

    Try this, for me it solved the problem. The problem is that the underlying kernel http.sys has it's own timeout and it will break the connection.

    http://mmmreddy.wordpress.com/2013/07/11/wcf-use-of-http-transport-sharing-persistent-tcp-sessions/
    
    netsh http add timeout timeouttype=idleconnectiontimeout value=120
    
    0 讨论(0)
  • 2020-12-08 16:57

    It turns out that this issue was caused by the Connection Timeout value used by HTTP.sys and that can be specified through IIS Manager through the Advanced Settings for the individual site. This value is configured by default to timeout a connection when both the header and body haven't been received within 120 seconds. If a pulse of data from the body is received then the server restarts a timer (Timer_EntityBody) within the timeout value then the timer is reset to wait for additional data.

    Connection Time-out setting in IIS

    This is just as the documentation concerning Timer_EntityBody and connectionTimeout specifies, however it was hard to pinpoint because it appears that IIS Express ignores the connectionTimeout value specified in the limits element in applicationhost.config regardless of what the documentation says. In order to determine this I had to install the full version of IIS on my development machine and modify the setting above after hosting my site there.

    Since we are hosting the real service under IIS on Windows 2008 the above solution will work for me however the question still remains on how to properly modify the Connection Timeout value in cases where you are Self Hosting.

    0 讨论(0)
  • 2020-12-08 17:00

    Probably long shot, but... Check your IIS app pool if it has Ping enabled. It's in advanced settings, Process Model grouping.

    0 讨论(0)
  • 2020-12-08 17:01

    Did you consider http://support.microsoft.com/kb/946086 ?

    I observed such streaming interrupts in my ISAPI-Extensions. After switching off buffering in IIS 7 according to this suppport note, everthing worked fined.

    0 讨论(0)
  • 2020-12-08 17:11

    Judging from the error:

    The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '23:59:59.9110000'

    Looks like this is a simple TCP timeout.

    You can verify it by running the application as self-hosted, and then running this command in console:

    netstat -no |find "xxxxx"
    

    where xxxxx is the PID of your server process. This command will show you the connections your server has established and refresh every second.

    Try to connect with the client and see what happens. Most likely, you'll see "CLOSE_WAIT" or "TIME_WAIT" on your connection after around 100-120 seconds - which will mean it was aborted due to timeout.

    This sould be fixable by adding the following to your config:

    <httpTransport maxBufferSize="65536"                        
                 maxReceivedMessageSize="2147483647"
                 maxBufferPoolSize="2147483647"
                 transferMode="Streamed"
                 keepAliveEnabled="true" /> <!-- Here -->
    

    The parameter is explained here

    0 讨论(0)
提交回复
热议问题