From deb974794c95078d69b425b9cd8044b4e1b01145 Mon Sep 17 00:00:00 2001 From: Boris Dutkin Date: Thu, 11 Nov 2021 10:42:13 +0200 Subject: [PATCH] Update server.go While running the example, refreshing the index.html page will cause an errors in the server.go. Since using infinite for loop on line (:14), you need to break it if error occurred. --- cookbook/websocket/net/server.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cookbook/websocket/net/server.go b/cookbook/websocket/net/server.go index 9d478a53..eb308302 100644 --- a/cookbook/websocket/net/server.go +++ b/cookbook/websocket/net/server.go @@ -16,6 +16,7 @@ func hello(c echo.Context) error { err := websocket.Message.Send(ws, "Hello, Client!") if err != nil { c.Logger().Error(err) + break } // Read @@ -23,6 +24,7 @@ func hello(c echo.Context) error { err = websocket.Message.Receive(ws, &msg) if err != nil { c.Logger().Error(err) + break } fmt.Printf("%s\n", msg) }