mirror of
https://github.com/aljazceru/signal-cli-rest-api.git
synced 2025-12-18 23:24:20 +01:00
Do not set any deadlines in websocket connection
* The websocket rfc doesn't specify what to do when a client doesn't respond to a ping message. It just states that it must respond with a pong message. But it is unclear what should happen when the client doesn't respond with a pong message. So instead of closing the connection, we are keeping the connection open as long as possible.
This commit is contained in:
@@ -307,8 +307,7 @@ func (a *Api) handleSignalReceive(ws *websocket.Conn, number string) {
|
||||
|
||||
func wsPong(ws *websocket.Conn) {
|
||||
ws.SetReadLimit(512)
|
||||
ws.SetReadDeadline(time.Now().Add(pongWait))
|
||||
ws.SetPongHandler(func(string) error { ws.SetReadDeadline(time.Now().Add(pongWait)); return nil })
|
||||
ws.SetPongHandler(func(string) error { log.Debug("Received pong"); return nil })
|
||||
for {
|
||||
_, _, err := ws.ReadMessage()
|
||||
if err != nil {
|
||||
@@ -322,7 +321,6 @@ func wsPing(ws *websocket.Conn) {
|
||||
for {
|
||||
select {
|
||||
case <-pingTicker.C:
|
||||
ws.SetWriteDeadline(time.Now().Add(writeWait))
|
||||
if err := ws.WriteMessage(websocket.PingMessage, []byte{}); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user