RTC Forums

Subscription => Support => Topic started by: thomh on February 11, 2021, 04:05:10 PM



Title: TCP port connections in CLOSE_WAIT state
Post by: thomh on February 11, 2021, 04:05:10 PM
Hi,

I have an RTC server with a browser front end. What happens to the server thread when a browser makes a request to the server and the browser is closed before the server response is received back?

I did a netstat -ano  on the server port and showed a lot of open TCP port connections that are in a CLOSE_WAIT state.

What does this mean?

Thanks,
Thom


Title: Re: TCP port connections in CLOSE_WAIT state
Post by: D.Tkalcec (RTC) on February 11, 2021, 04:18:11 PM
If you are using the TRtcHttpServer component on Windows and with its default non-blocking setting ("Blocking" property is set to FALSE), then the component will be using a Thread ONLY when data is actively being sent, received or processed. If no data is being sent, received or processed (which normally only happens in "user" code), then no Threads would be used, regardless of the state of a TCP/IP connection.

Connections which are in some semi-closed state, or connections which are open but are NOT actively used (no data is being sent, received or processed) would still use some System resources like a Socket Handle and some RAM (Objects holding connection info), but they won't be using any Threads (no CPU drain) ... provided your Server is running on Windows and the "Blocking" property on the "TRtcHttpServer" component is set to FALSE.

Connections which have been closed by one side but not the other (CLOSE_WAIT and TIME_WAIT state) would normally be closed by the Socket API after a time-out, which could be anywhere between a few minutes and a couple of hours, depending on your OS preferences.

Best Regards,
Danijel Tkalcec