Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can a TCP/IP Stack be killed programmatically?

Tags:

c#

tcp

Our server application is listening on a port, and after a period of time it no longer accepts incoming connections. (And while I'd love to solve this issue, it's not what I'm asking about here;)

The strange this is that when our app stops accepting connections on port 44044, so does IIS (on port 8080). Killing our app fixes everything - IIS starts responding again.

So the question is, can an application mess up the entire TCP/IP stack? Or perhaps, how can an application do that?

Senseless detail: Our app is written in C#, under .Net 2.0, on XP/SP2.

Clarification: IIS is not "refusing" the attempted connections. It is never seeing them. Clients are getting a "server did not respond in a timely manner" message (using the .Net TCP Client.)

like image 734
Gene Avatar asked Jun 24 '26 22:06

Gene


2 Answers

You may well be starving the stack. It is pretty easy to drain in a high open/close transactions per second environment e.g. webserver serving lots of unpooled requests.

This is exhacerbated by the default TIME-WAIT delay - the amount of time that a socket has to be closed before being recycled defaults to 90s (if I remember right)

There are a bunch of registry keys that can be tweaked - suggest at least the following keys are created/edited

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters

TcpTimedWaitDelay = 30
MaxUserPort = 65534 
MaxHashTableSize = 65536 
MaxFreeTcbs = 16000 

Plenty of docs on MSDN & Technet about the function of these keys.

like image 183
stephbu Avatar answered Jun 27 '26 11:06

stephbu


You haven't maxed out the available port handles have you ?
netstat -a

I saw something similar when an app was opening and closing ports (but not actually closing them correctly).

like image 44
RichS Avatar answered Jun 27 '26 12:06

RichS



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!