From 5bde25d5b583fbad6059bc8f3a7ae2290c8da23a Mon Sep 17 00:00:00 2001 From: AreYouScared Date: Tue, 28 Jan 2020 12:35:56 -0500 Subject: [PATCH] Fixes stuck Go-routine Fixes https://github.com/pterodactyl/panel/issues/1816 Credit goes to https://github.com/matthewpi --- websocket.go | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/websocket.go b/websocket.go index e9a9921..062d23a 100644 --- a/websocket.go +++ b/websocket.go @@ -187,17 +187,13 @@ func (rt *Router) routeWebsocket(w http.ResponseWriter, r *http.Request, ps http // Listen for different events emitted by the server and respond to them appropriately. go func() { - for { - select { - case d := <-eventChannel: - handler.SendJson(&WebsocketMessage{ - Event: d.Topic, - Args: []string{d.Data}, - }) - } + for d := range eventChannel { + handler.SendJson(&WebsocketMessage{ + Event: d.Topic, + Args: []string{d.Data}, + }) } }() - // Sit here and check the time to expiration on the JWT every 30 seconds until // the token has expired. If we are within 3 minutes of the token expiring, send // a notice over the socket that it is expiring soon. If it has expired, send that