Skip to content

Commit

Permalink
rpc: set websocket read deadline after Ping
Browse files Browse the repository at this point in the history
  • Loading branch information
jmank88 committed Sep 9, 2021
1 parent 0755c7a commit 729bcfd
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions rpc/websocket.go
Expand Up @@ -37,6 +37,7 @@ const (
wsWriteBuffer = 1024
wsPingInterval = 60 * time.Second
wsPingWriteTimeout = 5 * time.Second
wsPongTimeout = 30 * time.Second
wsMessageSizeLimit = 15 * 1024 * 1024
)

Expand Down Expand Up @@ -287,6 +288,7 @@ func (wc *websocketCodec) pingLoop() {
wc.jsonCodec.encMu.Lock()
wc.conn.SetWriteDeadline(time.Now().Add(wsPingWriteTimeout))
wc.conn.WriteMessage(websocket.PingMessage, nil)
wc.conn.SetReadDeadline(time.Now().Add(wsPongTimeout))
wc.jsonCodec.encMu.Unlock()
timer.Reset(wsPingInterval)
}
Expand Down

0 comments on commit 729bcfd

Please sign in to comment.