File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -125,11 +125,16 @@ func (c *client) listenWebsocket() {
125125 log .Printf ("Unexpected websocket close error: %v\n " , readErr )
126126 }
127127
128+ // If client fails to send ping messages
128129 if strings .Contains (strings .ToLower (readErr .Error ()), "i/o timeout" ) {
129130 log .Printf ("No ping received from client: %v\n " , c .conn .RemoteAddr ())
130131
131132 closeMessage := websocket .FormatCloseMessage (websocket .CloseNoStatusReceived , "No ping received!" )
132- c .conn .WriteControl (websocket .CloseMessage , closeMessage , time .Now ().Add (5 * time .Second )) //nolint:errcheck
133+
134+ writeErr := c .conn .WriteControl (websocket .CloseMessage , closeMessage , time .Now ().Add (5 * time .Second ))
135+ if writeErr != nil {
136+ log .Printf ("Error while sending close message: %v\n " , writeErr )
137+ }
133138 } else if strings .Contains (strings .ToLower (readErr .Error ()), "an existing connection was forcibly closed by the remote host" ) {
134139 log .Printf ("Connection to client lost: %v\n " , c .conn .RemoteAddr ())
135140 }
Original file line number Diff line number Diff line change @@ -324,5 +324,10 @@ func (ws *Server) shutdown() error {
324324 ctx , cancel := context .WithTimeout (context .Background (), 15 * time .Second )
325325 defer cancel ()
326326
327- return ws .server .Shutdown (ctx )
327+ err := ws .server .Shutdown (ctx )
328+ if err != nil {
329+ return fmt .Errorf ("error during server shutdown: %w" , err )
330+ }
331+
332+ return nil
328333}
You can’t perform that action at this time.
0 commit comments