fasthttp websocket: panic nil: websocket.(*Conn)

使用Fiber v2.38.1,后者又使用fasthttp/websocket v1.5.0

应用程序崩溃并出现以下错误:

2022-10-15T04:05:42.983563+00:00 app[web.1]: time="2022-10-15T04:05:42Z" level=info msg="close msg received: &{418 close}"

2022-10-15T04:05:42.983564+00:00 app[web.1]: conn is nil: false, msg: &{418 close <nil> conn 0}

2022-10-15T04:05:42.986035+00:00 app[web.1]: panic: runtime error: invalid memory address or nil pointer dereference

2022-10-15T04:05:42.986035+00:00 app[web.1]: [signal SIGSEGV: segmentation violation code=0x1 addr=0x78 pc=0x8db967]

2022-10-15T04:05:42.986036+00:00 app[web.1]: 

2022-10-15T04:05:42.986037+00:00 app[web.1]: goroutine 86 [running]:

2022-10-15T04:05:42.986037+00:00 app[web.1]: github.com/fasthttp/websocket.(*Conn).beginMessage(0x0, 0xc000348f60, 0x1)

2022-10-15T04:05:42.986037+00:00 app[web.1]:    /tmp/codon/tmp/cache/go-path/pkg/mod/github.com/fasthttp/websocket@v1.5.0/conn.go:479 +0x27

2022-10-15T04:05:42.986038+00:00 app[web.1]: github.com/fasthttp/websocket.(*Conn).NextWriter(0x0, 0x1)

2022-10-15T04:05:42.986038+00:00 app[web.1]:    /tmp/codon/tmp/cache/go-path/pkg/mod/github.com/fasthttp/websocket@v1.5.0/conn.go:520 +0x45

2022-10-15T04:05:42.986039+00:00 app[web.1]: github.com/fasthttp/websocket.(*Conn).WriteJSON(0xe79a80?, {0xc143a0, 0xc00041e600})

2022-10-15T04:05:42.986039+00:00 app[web.1]:    /tmp/codon/tmp/cache/go-path/pkg/mod/github.com/fasthttp/websocket@v1.5.0/json.go:24 +0x45

2022-10-15T04:05:42.986039+00:00 app[web.1]: github.com/kuchaguangjie/go-fit/model.(*WsClient).WriteMsg(0xc00056a280, 0xc00041e600)

conn.go:479在函数中崩溃于beginMessage()

if c.writer != nil {

我已经检查过它c不是零(如日志中所示),所以它是如何崩溃的......


顺便说一句,它部署在 heroku 上,我在 heroku 上看到以下日志:

2022-10-15T04:59:30.344791+00:00 heroku[路由器]: at=error code=H15 desc="空闲连接"

不确定它是否相关。


一只萌萌小番薯
浏览 123回答 1
1回答

千万里不及你

这是一个 fasthttp 错误,已修复v1.5.1-rc.8参考: https:&nbsp;//github.com/fasthttp/websocket/issues/30#issuecomment-1326860975
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Go