Michael Neale
Michael Neale

Reputation: 19478

In normal operation, how long will the TCP connection be kept open with websocket

Websocket is often done via a protocol upgrade from http - but even then - it is a layer on top (directly) of TCP.

Given that - how long can I expect a single TCP connection to be used underlying the websocket? how often will that connection have to be replaced (all without the client/server necessarily being aware).

Upvotes: 0

Views: 363

Answers (1)

Philipp
Philipp

Reputation: 69703

As Joakim Erdfelt commented, there is no way to know the exact timeout value of a TCP connection, because it is a value which can be configured individually on each system which takes part in the connection.

But note that TCP connections are usually only dropped when there was no communication for an extended period of time. You can prevent this from happening by sending small, meaningless keep-alive messages at regular intervals.

In my current application I am doing this by pinging the client every 10 seconds. This has the advantage that I also get a good statistic of network latency.

Upvotes: 1

Related Questions