You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is something strange in the Send function (lines 287 to 301 in
websocket/websocket.go):
On the line 297 we have this:
w, err := ws.frameWriterFactory.NewFrameWriter(payloadType)
And on the next line, instead of checking the error, we directly write to w:
_, err = w.Write(data)
But if there was an error, w is nil and calling w.Write(data) leads to a runtime
exception.
Also, at the very beginning of the function, there is a check for the err variable which
have not been affected at this point.
Here is my corrected version:
func (cd Codec) Send(ws *Conn, v interface{}) (err error) {
data, payloadType, err := cd.Marshal(v)
if err != nil {
return err
}
ws.wio.Lock()
defer ws.wio.Unlock()
w, err := ws.frameWriterFactory.NewFrameWriter(payloadType)
if err != nil {
return err
}
_, err = w.Write(data)
w.Close()
return err
}
Thanks
The text was updated successfully, but these errors were encountered:
by svinartchouk.alexis@free.fr:
The text was updated successfully, but these errors were encountered: