-
Notifications
You must be signed in to change notification settings - Fork 10.1k
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
Namespace connect event failed to trigger randomly. REDIS SENTINEL + SOCKETIO #3960
Comments
I have removed namespace and using namespace+channel to separate each room. It's working fine. Still unable to find why the namespace connection event is not triggered. |
Hi! I can't reproduce the issue you are experiencing. Does it happen randomly or are you able to reproduce consistently? |
its too random.. also it happen with ubuntu only. In windows I never had that issue. |
@darrachequesne Finally. I found where it's failing the actual use case you can test with. I did add some log where library trigger connection event and added log at the server code side where it receives connection event. Socket.io triggers the following line. It happened with Ubuntu with PM2 only. Maybe you can set up the following environment to troubleshoot the issue. |
Finally found the issue. Not working
Working
|
I'm also experiencing this intermittent issue when using a regex expression? |
@ChrisKatsaras the only possible explanation that I see is that there is another namespace (not dynamic) that gets the "connection" event first: io.of("/test").on("connection", (socket) => {
// triggered
});
io.of(/.*/).on("connection", (socket) => {
// not triggered
}); Could it be your case? |
@ChrisKatsaras Yes. You are right about the limited namespace. in my case, I have very little namespace like 4-5 so I just looped over them and make it work. It's not a great solution. but for me, it's working. @darrachequesne Yes, you are right about.. It's calling another namespace connection method that is not registered and emits is returning false because of no event listener registered. As I saw while debugging the namespace list was like ["/", "/namespaceABC"] but the connection method fns value was []. Maybe because it creating the default main namespace and I have not registered any event for it as the namespace list has "/" in it. |
@darrachequesne that seems like a good explanation of what would happen but I don't think so in my case 😓 |
So I did some testing again but sadly still didn't work as intended @darrachequesne . However, given my requirements, I've decided to go with the solution @bhavesh-webosmotic suggested 😄 |
OK, I guess we can close the issue now. Please reopen if needed. |
This shouldn't close before we could use back the dynamic workspaces with multi-nodes. |
Related: socketio/socket.io#3960
@tuntafag the issue was closed as I was not able to reproduce the problem: https://github.com/socketio/socket.io-fiddle/tree/issues/socket.io/3960 Could you please check? |
I'm also experiencing this intermittent issue when using a regex expression for dynamic namespace. But, In case:
Note: I have only one the code snippet for namespace instance in my app. This issue occurs when running on multiple node deployed in Kubernetes with many pods. Is there any solution for this issue ? My application has many namespaces so I needs using dynamic namespace instead of hard code. |
@FA-QuangLT as usual, if we cannot reproduce the issue, I'm afraid we won't be able to help you... |
@darrachequesne I think this issue only occurs when running on multiple node that deployed in Kubernetes with many pods using dynamic namespace. |
Namespaces that match the regex of a parent namespace will now be added as a child of this namespace: ```js const parentNamespace = io.of(/^\/dynamic-\d+$/); const childNamespace = io.of("/dynamic-101"); ``` Related: - socketio#4615 - socketio#4164 - socketio#4015 - socketio#3960
Namespaces that match the regex of a parent namespace will now be added as a child of this namespace: ```js const parentNamespace = io.of(/^\/dynamic-\d+$/); const childNamespace = io.of("/dynamic-101"); ``` Related: - socketio#4615 - socketio#4164 - socketio#4015 - socketio#3960
I have faced a strange issue with REDIS, Socket io. Sometimes connection events never trigger on the server.
I am using transports as WebSocket only.
The code works like 60 out of 40 times. But, that is too random.
The code is working fine most of the time. It only failed when the socket.io client failed to trigger the namespace connect event.
I did try to lower the socket version to V3 on both client and server but issues were the same.
FYI.
I do have handle code in the try-catch statement and also tried to add logs. But the strange thing is I never found any connection log on the server when this thing happen. for the successful connection I am getting all the logs.
I did try many ways to find the issue and added many logs. It was difficult for me to look into 24 instances for logs.
So, I tried to generate the engine id on my own to find the exact instance which has this issue.
The finding
NOTE: As I can not share actual ids and other information. I have replaced actual ids with random ids.
Server Code
Package on server-side
socket.js file
Middleware.js
Client Code
Package on client side
"socket.io-client": "^4.1.2",
LOGS
[PASS]Successfully connected client events logs look like on the server
[FAILED] When socket io failed to trigger connection event of the namespace.
The text was updated successfully, but these errors were encountered: