golangSocketChat
golangSocketChat copied to clipboard
This gets stuck in INFINITE LOOP
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
}
}