sio.wait() doesn't survive upgrade from http to https #731
Replies: 4 comments
-
Please review the troubleshooting section of the docs to learn how to generate logs. Then attach the logs showing the problem here. |
Beta Was this translation helpful? Give feedback.
-
Here's the failed log:
So I'd guess it's because I'm authenticating with http-basic-auth using a custom header, and the Auth header isn't getting preserved. If I specify
The code is extremely simple: import os
import socketio
ENDPOINT = 'https://dev.posichat.io/'
sio = socketio.Client(logger=True, engineio_logger=True)
@sio.on('debugnum')
def got_debugnum(data):
print(f"Got debugnum {data=}")
passwd = os.environ['HTTP_BASIC_AUTH']
sio.connect(ENDPOINT, headers={
"Authorization": f"Basic {passwd}",
})
assert sio.sid, "Failed to connect"
print(f"Connected with {sio.sid=}")
sio.wait() |
Beta Was this translation helpful? Give feedback.
-
So you are saying that you are passing a token or similar auth element on a non-encrypted connection? That is a terrible idea, you are exposing your tokens publicly. Maybe there is something to improve in the Socket.IO client with regards to how redirects are handled, but you definitely do not want things to work in the way you seem to suggest. |
Beta Was this translation helpful? Give feedback.
-
Yes, I understand the described behavior represents a real security problem, and not how our system should ever actually behave. The tokens should not ever be sent over http, but I tracked down this bug when the endpoint URL was accidentally specified as http instead of https. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
My webserver (nginx) has the common config to 308 any http requests to https. If I call
sio.connect()
with an http (not https) URL, everything seems to work fine until my code gets tosio.wait()
which after a couple seconds just returns without any error message or anything. But if I specify https manually in the endpoint, then thesio.wait()
waits forever like I expect.Beta Was this translation helpful? Give feedback.
All reactions