Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Concurrent write of websocket causes msg-gateway gateway panic #3144

Open
soluty opened this issue Feb 15, 2025 · 1 comment
Open

[BUG] Concurrent write of websocket causes msg-gateway gateway panic #3144

soluty opened this issue Feb 15, 2025 · 1 comment
Labels
bug Categorizes issue or PR as related to a bug.

Comments

@soluty
Copy link

soluty commented Feb 15, 2025

OpenIM Server Version

3.8.2-3.8.4都有

Operating System and CPU Architecture

Linux (AMD)

Deployment Method

Source Code Deployment

Bug Description and Steps to Reproduce

我搜到仓库里面之前有一个同样的issue并且fix掉了, 当时是由于漏加了一个锁导致, 但是我现在的源码是3.8.2, 我查了一下, 是有加那个锁的, 所以那个fix不能完全起作用, 应该还有哪些地方可能导致并发写同一个websocket的连接

panic: concurrent write to websocket connection
goroutine 515 [running]:
github.com/gorilla/websocket.(*messageWriter).flushFrame(0xc00eb35c70, 0x1, {0xc00d5083c9?, 0x0?, 0x0?})
/root/go/pkg/mod/github.com/gorilla/[email protected]/conn.go:632 +0x4b8
github.com/gorilla/websocket.(*Conn).WriteMessage(0xc002386160, 0xc00eb35cd8?, {0xc00d508200, 0x1c9, 0x200})
/root/go/pkg/mod/github.com/gorilla/[email protected]/conn.go:785 +0x126
github.com/openimsdk/open-im-server/v3/internal/msggateway.(*GWebSocket).WriteMessage(0xc0073a8180?, 0xc0013fe2c0?, {0xc00d508200?, 0xc00eb35d30?, 0x4a7c10?})
/repo/open-im-server/internal/msggateway/long_conn.go:88 +0x1c
github.com/openimsdk/open-im-server/v3/internal/msggateway.(*Client).writeBinaryMsg(0xc014160410, {0x7d1, {0x0, 0x0}, {0xc014730720, 0x22}, 0x0, {0x0, 0x0}, {0xc009d14240, ...}})
/repo/open-im-server/internal/msggateway/client.go:369 +0x18e
github.com/openimsdk/open-im-server/v3/internal/msggateway.(*Client).PushMessage(0xc014160410, {0x19176d8, 0xc018a03ec0}, 0xc003c91080)
/repo/open-im-server/internal/msggateway/client.go:325 +0x36b
github.com/openimsdk/open-im-server/v3/internal/msggateway.(*Server).pushToUser(0xc0012bcf30, {0x19176d8, 0xc018a03ec0}, {0xc004a05698, 0x14}, 0xc003c91080)
/repo/open-im-server/internal/msggateway/hub_server.go:150 +0x3b0
github.com/openimsdk/open-im-server/v3/internal/msggateway.(*Server).SuperGroupOnlineBatchPushOneMsg.func1()
/repo/open-im-server/internal/msggateway/hub_server.go:177 +0x45
github.com/openimsdk/tools/mq/memamq.(*MemoryQueue).initialize.func1()
/root/go/pkg/mod/github.com/openimsdk/[email protected]/mq/memamq/queue.go:54 +0x75
created by github.com/openimsdk/tools/mq/memamq.(*MemoryQueue).initialize in goroutine 1
/root/go/pkg/mod/github.com/openimsdk/[email protected]/mq/memamq/queue.go:51 +0x65

Screenshots Link

No response

@soluty soluty added the bug Categorizes issue or PR as related to a bug. label Feb 15, 2025
@OpenIM-Robot OpenIM-Robot changed the title [BUG] websocket的并发写导致msg-gateway网关panic [BUG] Concurrent write of websocket causes msg-gateway gateway panic Feb 15, 2025
@OpenIM-Robot
Copy link

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


OpenIM Server Version

All 3.8.2-3.8.4

Operating System and CPU Architecture

Linux (AMD)

Deployment Method

Source Code Deployment

Bug Description and Steps to Reproduce

I found that there was the same issue in the warehouse and the fix dropped. It was caused by a lock being added, but my current source code is 3.8.2. I checked it and it was added, so that one. Fix does not work completely. What else should be possible to concurrently write connections to the same websocket

panic: concurrent write to websocket connection
goroutine 515 [running]:
github.com/gorilla/websocket.(*messageWriter).flushFrame(0xc00eb35c70, 0x1, {0xc00d5083c9?, 0x0?, 0x0?})
/root/go/pkg/mod/github.com/gorilla/[email protected]/conn.go:632 +0x4b8
github.com/gorilla/websocket.(*Conn).WriteMessage(0xc002386160, 0xc00eb35cd8?, {0xc00d508200, 0x1c9, 0x200})
/root/go/pkg/mod/github.com/gorilla/[email protected]/conn.go:785 +0x126
github.com/openimsdk/open-im-server/v3/internal/msggateway.(*GWebSocket).WriteMessage(0xc0073a8180?, 0xc0013fe2c0?, {0xc00d508200?, 0xc00eb35d30?, 0x4a7c10?})
/repo/open-im-server/internal/msggateway/long_conn.go:88 +0x1c
github.com/openimsdk/open-im-server/v3/internal/msggateway.(*Client).writeBinaryMsg(0xc014160410, {0x7d1, {0x0, 0x0}, {0xc014730720, 0x22}, 0x0, {0x0, 0x0}, {0xc009d14240, ...}})
/repo/open-im-server/internal/msggateway/client.go:369 +0x18e
github.com/openimsdk/open-im-server/v3/internal/msggateway.(*Client).PushMessage(0xc014160410, {0x19176d8, 0xc018a03ec0}, 0xc003c91080)
/repo/open-im-server/internal/msggateway/client.go:325 +0x36b
github.com/openimsdk/open-im-server/v3/internal/msggateway.(*Server).pushToUser(0xc0012bcf30, {0x19176d8, 0xc018a03ec0}, {0xc004a05698, 0x14}, 0xc003c91080)
/repo/open-im-server/internal/msggateway/hub_server.go:150 +0x3b0
github.com/openimsdk/open-im-server/v3/internal/msggateway.(*Server).SuperGroupOnlineBatchPushOneMsg.func1()
/repo/open-im-server/internal/msggateway/hub_server.go:177 +0x45
github.com/openimsdk/tools/mq/memamq.(*MemoryQueue).initialize.func1()
/root/go/pkg/mod/github.com/openimsdk/[email protected]/mq/memamq/queue.go:54 +0x75
created by github.com/openimsdk/tools/mq/memamq.(*MemoryQueue).initialize in goroutine 1
/root/go/pkg/mod/github.com/openimsdk/[email protected]/mq/memamq/queue.go:51 +0x65

Screenshots Link

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

No branches or pull requests

2 participants