mirror of
https://github.com/bbernhard/signal-cli-rest-api.git
synced 2026-05-23 14:14:16 +00: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:
parent
094e42059d
commit
795b4c3f99
@ -307,8 +307,7 @@ func (a *Api) handleSignalReceive(ws *websocket.Conn, number string) {
|
|||||||
|
|
||||||
func wsPong(ws *websocket.Conn) {
|
func wsPong(ws *websocket.Conn) {
|
||||||
ws.SetReadLimit(512)
|
ws.SetReadLimit(512)
|
||||||
ws.SetReadDeadline(time.Now().Add(pongWait))
|
ws.SetPongHandler(func(string) error { log.Debug("Received pong"); return nil })
|
||||||
ws.SetPongHandler(func(string) error { ws.SetReadDeadline(time.Now().Add(pongWait)); return nil })
|
|
||||||
for {
|
for {
|
||||||
_, _, err := ws.ReadMessage()
|
_, _, err := ws.ReadMessage()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -322,7 +321,6 @@ func wsPing(ws *websocket.Conn) {
|
|||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-pingTicker.C:
|
case <-pingTicker.C:
|
||||||
ws.SetWriteDeadline(time.Now().Add(writeWait))
|
|
||||||
if err := ws.WriteMessage(websocket.PingMessage, []byte{}); err != nil {
|
if err := ws.WriteMessage(websocket.PingMessage, []byte{}); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user