Reputation: 15812
I'm trying to implement a protocol to match-up the received Pongs with the corresponding Pings.
But what do I do about the Pings I send but don't receive a Pong? Could this happen? Or is it guaranteed that all pings will have corresponding Pongs, and that never receiving a Pong indicates loss of connectivity? The websocket protocol document is silent with regard to this.
Upvotes: 1
Views: 880
Reputation: 2760
A conforming WebSocket implimentation must return a pong upon recieving a ping. In general, no pong after a reasonable amount of time means either a network error or something else is busy or broken on the remote endpoint. There are a few caveats.
Upvotes: 2
Reputation: 69703
Websockets are based on the TCP protocol which ensures that all packets are processed in-order and that lost or damaged packets are retransmitted before continuing to process the incomming data.
So the only possible explanation for a missing pong is an error in the implementation of the ping/pong protocol on the other side of the connection.
The reliablility of the TCP protocol and its ordering can easily be seen while webbrowsing. When you have a bad internet connection, websites loading might get interrupted while in progress, but those parts which do load are always in the right order and without any errohEThgf%$/GHfDw(&IjfdsAyW$§REggnfdER§$HHxM+FD5
Upvotes: 2