XiaoMiku01 / douyin-live-go

抖音(web) 弹幕爬虫 golang 实现
GNU General Public License v3.0
127 stars 40 forks source link

websocket异常 #3

Open zzf-0922 opened 1 year ago

zzf-0922 commented 1 year ago

在程序运行一段时间之后会出现socket异常,异常也各不相同 panic: websocket: close 1006 (abnormal closure): unexpected EOF

goroutine 67 [running]: main.(Room).read(0xc000092000) D:/workStation/go/douyin-live-go/room.go:123 +0x2e5 created by main.(Room).Connect D:/workStation/go/douyin-live-go/room.go:114 +0x314

panic: concurrent write to websocket connection

goroutine 20 [running]: github.com/gorilla/websocket.(messageWriter).flushFrame(0xc00060af90, 0x1, {0x0?, 0x0?, 0x0?}) C:/Users/Administrator/go/pkg/mod/github.com/gorilla/websocket@v1.5.0/conn.go:617 +0x52b github.com/gorilla/websocket.(messageWriter).Close(0x0?) C:/Users/Administrator/go/pkg/mod/github.com/gorilla/websocket@v1.5.0/conn.go:731 +0x45 github.com/gorilla/websocket.(Conn).beginMessage(0xc000135760, 0xc00060afc0, 0x2) C:/Users/Administrator/go/pkg/mod/github.com/gorilla/websocket@v1.5.0/conn.go:480 +0x42 github.com/gorilla/websocket.(Conn).NextWriter(0xc000135760, 0x2) C:/Users/Administrator/go/pkg/mod/github.com/gorilla/websocket@v1.5.0/conn.go:520 +0x45 github.com/gorilla/websocket.(Conn).WriteMessage(0x0?, 0x0?, {0xc00020c854, 0x4, 0x4}) C:/Users/Administrator/go/pkg/mod/github.com/gorilla/websocket@v1.5.0/conn.go:773 +0x152 main.(Room).send(0xc00005d920) D:/workStation/go/douyin-live-go/room.go:156 +0xa5 created by main.(*Room).Connect D:/workStation/go/douyin-live-go/room.go:115 +0x35c

ahkimkoo commented 3 months ago

隔一段时间以后就收不到消息了。我的思路是,隔5分钟就并行启动另外一个连接,新的连接能收到消息之后退出老的。在交替的这段时间,可以用msgid避免重复发送消息。 感谢作者的付出。这是我看到的众多抖音抓包里最优秀的一个,轻便,灵活。希望作者能够持续更新。