fix: avoid gobwas/ws pbytes.GetLen panic

This commit is contained in:
wwqgtxx 2023-12-06 12:02:50 +08:00
parent ed210ee403
commit f572e7fba8

View file

@ -65,6 +65,11 @@ type WebsocketConfig struct {
// Read implements net.Conn.Read()
// modify from gobwas/ws/wsutil.readData
func (wsc *websocketConn) Read(b []byte) (n int, err error) {
defer func() { // avoid gobwas/ws pbytes.GetLen panic
if value := recover(); value != nil {
err = fmt.Errorf("websocket error: %s", value)
}
}()
var header ws.Header
for {
n, err = wsc.reader.Read(b)