-
Notifications
You must be signed in to change notification settings - Fork 712
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ping/pong to websocket protocol #995
Conversation
Also needed for the pipes websocket, no? And do we ever call codec.Close()? |
re: pipes. probably, actually.
|
acc9c75
to
83222d7
Compare
@tomwilkie, added ping to all probe/app websockets (I think), wdyt? |
83222d7
to
1a90bed
Compare
} | ||
|
||
// Ping adds a periodic ping to a websocket connection. | ||
func Ping(c *websocket.Conn) Websocket { |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
e51bd22
to
aed940a
Compare
Tested this by opening a websocket (via nginx) to /api/control/ws, and seeing it be terminated after 60s. With this patch (and Edit: rebased and squashed. |
bbdce64
to
177805b
Compare
177805b
to
cfc0714
Compare
if err != nil { | ||
// log.Info("Upgrade:", err) | ||
return | ||
} | ||
conn := xfer.Ping(wsConn) |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
Looking better. If I understand this right, the probe will now ping the app and the app ping the probe? Not problem with that I guess. |
|
@@ -44,5 +156,25 @@ func ReadJSONfromWS(c *websocket.Conn, v interface{}) error { | |||
// One value is expected in the message. | |||
err = io.ErrUnexpectedEOF | |||
} | |||
if err == nil { | |||
err = p.conn.SetReadDeadline(mtime.Now().Add(pongWait)) | |||
} |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
65ad687
to
e39ce62
Compare
// Ping adds a periodic ping to a websocket connection. | ||
func Ping(c *websocket.Conn) Websocket { | ||
p := &pingingWebsocket{conn: c} | ||
p.conn.SetPongHandler(p.pong) |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
e39ce62
to
35fe886
Compare
LGTM once tests pass. |
Add ping/pong to websocket protocol
Fixes #828
Also made the websocket codec
WaitForReadError
return the error.