2

I'm connecting a client with websocket through Nginx (as a reverse proxy) to an asp.net core application. Between server and client there are heartbeat commands to keep websocket connection open.

My Problem is when a client disconnects by unplugging the network cable the connection remains open. I would like to set a timeout that when the client doesn't send anything for a certain time that the connection gets closed.

I tried multiple timeouts without any effect. (proxy_send_timeout, client_body_timeout, keepalive_timeout, send_timeout...) The only timeout I managed to set was proxy_read_timeout. What I didn't like was that this timeout was reset every time the server send anything (and not the client).

Which timeout do I have to set to disconnect the client if the client doesn't send anything for x seconds?

Many thanks in advanced!

1 Answer 1

2

I think you should also check system tcp timeout's,

For linux based.

/proc/sys/net/ipv4/tcp_keepalive_time
/proc/sys/net/ipv4/tcp_keepalive_intvl
/proc/sys/net/ipv4/tcp_keepalive_probes
/proc/sys/net/ipv4/tcp_retries2

For windows based,

HKEY_LOCAL_MACHINE \SYSTEM \CurrentControlSet \Services: \Tcpip \Parameters

TcpInitialRTT: Defines what the initial time-out settings are for new connections. This number in seconds is doubled each time it retransmits before timing a connection out. Defaults to 3.

TcpMaxConnectRetransmissions: Defines the number of retransmissions before timing a connection out. Defaults to 5.
1
  • Many thanks for your response. I will give it a try. The only thing I'm concerned about is, that this would also affect all other http requests to this server. (beside websocket)
    – Mathias
    Apr 29, 2019 at 6:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .