golangSocketChat icon indicating copy to clipboard operation
golangSocketChat copied to clipboard

This gets stuck in INFINITE LOOP

Open Longwater1234 opened this issue 1 year ago • 0 comments

https://github.com/motyar/golangSocketChat/blob/7afef5bc7b2833cf409df07fbf6ff93e6181c50b/ws.go#L43

If the client disconnects, the app goes to infinite loop printing the above line. The solution is to add return after line 43.

          //Broadcast message to all
		 for cs, _ := range ActiveClients {
                  if err = websocket.Message.Send(cs.websocket, clientMessage); err != nil {
                  // It could not send message to a peer
                  log.Println("Could not send message to ", cs.IP, err.Error())
                  return  // <-- SOLUTION, add this here to exit loop
            }
        }

Longwater1234 avatar Feb 02 '23 15:02 Longwater1234