Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set keep alive interval for HTTP connection in WCF

Tags:

.net

wcf

Http transport channel in WCF uses persistent HTTP connections by default. How to control keep alive timeout for those connections? Default value is 100s. I found that value by monitoring application in Procmon. I haven't found any setting in http transport binding element which configures this timeout. Is there any .NET class which can control that timeout?

like image 308
Ladislav Mrnka Avatar asked Aug 12 '10 09:08

Ladislav Mrnka


2 Answers

Take a look here:

http://web.archive.org/web/20080721055556/http://blog.magenic.com/blogs/jons/archive/2007/05/04/The-Tao-of-Microsoft-WCF-CustomBinding-Configuration-Elements.aspx

There is a detailed discussion of manipulating the keep alive property during an http connection.

like image 98
NakedBrunch Avatar answered Sep 29 '22 04:09

NakedBrunch


I found the solution for this. 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

Also, this question is similar to this What 130 second timeout is killig my WCF streaming service call?

like image 45
Luiz Felipe Avatar answered Sep 29 '22 03:09

Luiz Felipe