The websocket.IsUnexpectedCloseError function is useful for identifying application and protocol errors. This server application works with a client application running in the browser. The client application does not explicitly close the websocket. The only expected close message from the client ha
()
| 26 | // websocket.CloseGoingAway. All other close messages are likely the |
| 27 | // result of an application or protocol error and are logged to aid debugging. |
| 28 | func ExampleIsUnexpectedCloseError() { |
| 29 | for { |
| 30 | messageType, p, err := c.ReadMessage() |
| 31 | if err != nil { |
| 32 | if websocket.IsUnexpectedCloseError(err, websocket.CloseGoingAway) { |
| 33 | log.Printf("error: %v, user-agent: %v", err, req.Header.Get("User-Agent")) |
| 34 | } |
| 35 | return |
| 36 | } |
| 37 | processMessage(messageType, p) |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | func processMessage(mt int, p []byte) {} |
| 42 |
nothing calls this directly
no test coverage detected