Skip to content

Commit

Permalink
Setting ReadDeadline every time we receive an incoming message (#972)
Browse files Browse the repository at this point in the history
  • Loading branch information
gracegoo-stripe authored Sep 15, 2022
1 parent 2d9eef8 commit 91f03bf
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions pkg/websocket/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,11 +304,6 @@ func (c *Client) changeConnection(conn *ws.Conn) {
func (c *Client) readPump() {
defer c.wg.Done()

err := c.conn.SetReadDeadline(time.Now().Add(c.cfg.PongWait))
if err != nil {
c.cfg.Log.Debug("SetReadDeadline error: ", err)
}

c.conn.SetPongHandler(func(string) error {
c.cfg.Log.WithFields(log.Fields{
"prefix": "websocket.Client.readPump",
Expand All @@ -323,6 +318,11 @@ func (c *Client) readPump() {
})

for {
c.cfg.Log.Debug("Setting read deadline: ")
err := c.conn.SetReadDeadline(time.Now().Add(c.cfg.PongWait))
if err != nil {
c.cfg.Log.Debug("SetReadDeadline error: ", err)
}
_, data, err := c.conn.ReadMessage()
if err != nil {
select {
Expand Down

0 comments on commit 91f03bf

Please sign in to comment.