fix: avoid gobwas/ws pbytes.GetLen panic
This commit is contained in:
parent
ed210ee403
commit
f572e7fba8
1 changed files with 5 additions and 0 deletions
|
@ -65,6 +65,11 @@ type WebsocketConfig struct {
|
||||||
// Read implements net.Conn.Read()
|
// Read implements net.Conn.Read()
|
||||||
// modify from gobwas/ws/wsutil.readData
|
// modify from gobwas/ws/wsutil.readData
|
||||||
func (wsc *websocketConn) Read(b []byte) (n int, err error) {
|
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
|
var header ws.Header
|
||||||
for {
|
for {
|
||||||
n, err = wsc.reader.Read(b)
|
n, err = wsc.reader.Read(b)
|
||||||
|
|
Loading…
Reference in a new issue