justcoding121 / titanium-web-proxy

A cross-platform asynchronous HTTP(S) proxy server in C#.
MIT License
1.92k stars 598 forks source link

ProxyServer its TcpConnectionFactory seems to not cleanup all connections #919

Open faucetcollector opened 2 years ago

faucetcollector commented 2 years ago

Version: 3.1.1434-beta (also 3.1.1397)

After Stopping the proxy server and even disposing it I noticed there are still some sockets in CLOSE_WAIT that don't go away (not even after 4 minutes)

image

The number of open sockets matches the number of connections still referenced in the TcpConnectionFactory its disposalBag - even tho the TcpConnectionFactory is already disposed (disposed property equals true). See this snapshot I took after stopping the ProxyServer:

image

Any clues why this is happening?

faucetcollector commented 2 years ago

The proxy is used by a browser. I noticed that I closed the proxy before terminating the browser - so it seems any requests that come in while the proxy is stopping are not always correctly cleaned up. Now that I'm first closing the browser and then shutting down the proxy the issue is resolved.