sid's don't match #721
Replies: 18 comments
-
To get the |
Beta Was this translation helpful? Give feedback.
-
Thanks, I'll try on Monday and let you know. |
Beta Was this translation helpful? Give feedback.
-
It works, but I had to move the |
Beta Was this translation helpful? Give feedback.
-
On the server side though, I store the sid in my flask session. And when I try to read it later in the join event, the |
Beta Was this translation helpful? Give feedback.
-
@cbasavaraj the documentation explains what the limitations of the user session are when it is used from a Socket.IO event. |
Beta Was this translation helpful? Give feedback.
-
I just went back and read the limitations again. They talk mostly about the socketio session fork not being available to HTTP routes. (I am already using redis for this purpose). Here, if you see my server side code (above), the But like I said, not a big issue. |
Beta Was this translation helpful? Give feedback.
-
Can you share how you initialize your |
Beta Was this translation helpful? Give feedback.
-
I use the factory pattern. Here are the relevant portions:
|
Beta Was this translation helpful? Give feedback.
-
Which server-side session type are you using? Have you checked if the changes that you are making are being saved to the session? |
Beta Was this translation helpful? Give feedback.
-
I'm using
|
Beta Was this translation helpful? Give feedback.
-
Somehow I missed this before. So you are saying that the same server records the session correctly with the client is JS, and it doesn't when the client is Python? That has to be caused by some different in the logic of your client, right? It has to be that the sequence of event handlers called by each client is different. In that case, my suggestion is that you enable logging in the server, and then capture a log session for the JS client and another for the Python client. Then we can look at the differences and hopefully understand what's happening. |
Beta Was this translation helpful? Give feedback.
-
Yes, works with JS but not with a dummy client in Python (the real api client will be a mobile app).
Logs for JS first. Note that
Logs with the python-socketio client:
|
Beta Was this translation helpful? Give feedback.
-
You haven't enabled Socket.IO logs in the server. See the troubleshooting section of the logs for help on doing this. |
Beta Was this translation helpful? Give feedback.
-
Ah, it's true that when I first added Socket.IO, I had a lot of logs. Then I kinda disabled them by setting the level to Warning, but later I never got back so many logs. Did the defaults change? I mean was it
In any case, I'll check on Monday and let you know. Thanks for the patience! |
Beta Was this translation helpful? Give feedback.
-
@cbasavaraj Yes, but WebSocket has a single request, you are not going to see anything in the log until the end of the connection, since requests are logged when they end, not when they start. |
Beta Was this translation helpful? Give feedback.
-
Hi Miguel, I am unable to get any more logs than what I've pasted above. I updated my SocketIO initialization to:
and this is my socketion.run call:
Tried
but that's it. Don't know what else I can try. I am using the latest versions of all the relevant libraries. |
Beta Was this translation helpful? Give feedback.
-
There should be additional logs when you add the |
Beta Was this translation helpful? Give feedback.
-
Kinda busy this week at work. Will get back to this a bit later, thanks! |
Beta Was this translation helpful? Give feedback.
-
Hi Miguel,
I have a flask-socketio server which must communicate with web browsers (JavaScript) as well as an API for mobile users. In order to test the API socketio functions, I've written a small python-socketio client. But the sid shown in this client is not the same as the sid reported on the server. To make it clearer:
Server side blueprint for API:
Client simulation:
The
sid
reported by the server at the linelogger.info(f"Connect from api: {request.sid}")
is not the same as the sid reported by the client atlogger.info(f"Connected: {sio.sid}")
(which is the same sid atlogger.info(f"sid: {sio.sid}")
For the equivalent in JavaScript, I don't have any problem. (The sids match). Can you see why this could be happening? Thanks
Beta Was this translation helpful? Give feedback.
All reactions