-
-
Notifications
You must be signed in to change notification settings - Fork 574
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
ConnectionRefusedError not working #487
Comments
Sorry, but I can't reproduce. I get the expected
|
Hmm not sure why reproduction isn't working. On my end, downgrading to 4.3.1 solves the issue so it seems to be something introduced in 4.4.0. I'm on Ubuntu 20.04 but not sure if that is relevant. I'll investigate further. |
Sorry, I gave your code another run today and I do see the problem. I must have put your server on the standard 8000 port yesterday, instead of the custom 8002 that you are using. |
I raise ConnectionRefusedError('authentication failed') in But the client only got The goal is to get the
======================================================================
|
@ysde can you please run your application with |
@miguelgrinberg I think this issue might have resurfaced? here's a repro:
import socketio
from socketio.exceptions import ConnectionRefusedError
sock = socketio.ASGIApp(
socketio.AsyncServer(
async_mode="asgi",
monitor_clients=False,
engineio_logger=True
),
)
@sock.engineio_server.event
async def connect(sid, environ):
# raise Exception('custom')
raise ConnectionRefusedError('custom')
# client.py
import asyncio
import socketio
import traceback
async def test():
c = socketio.AsyncClient()
try:
await c.connect('ws://localhost:8002')
await asyncio.sleep(1)
await c.disconnect()
await asyncio.sleep(1)
except:
traceback.print_exc()
asyncio.run(test()) here's what i see from the server after running
the client never raises an exception ... based on the logs, it looks like the server sends out the connection refused message but doesn't actually refuse the connection? thanks! |
@databasedav the Socket.IO protocol changed and the way this works had to change to accommodate the new version of the protocol. A connection rejected exception triggers a |
@miguelgrinberg ok got it, so it's up to the client to disconnect after getting a edit: ideally i want to send the client the reason for the rejection and then close the connection without invoking my disconnect handler (which undoes stuff done after an unrefused connection) |
@databasedav the disconnect handler should not be invoked for a rejected connection. Are you saying that it is being invoked in your application? The client should be disconnecting on its own after receiving the rejection and invoking the |
Hi, is this issue solved? I use Python for server and Javascript for client and I can not get ConnectionRefusedError exception at client. server-side (Python):
client-side (Javascript):
ConnectionRefusedError do not even emit disconnect, or connect_error event at all.
Thanks in advance. |
@kouohhashi this package has no control over how the JavaScript client reports connection errors. See the |
For others coming here with the same error:
or
|
This is on Python 3.8.2 with
and you can reproduce with
and running
uvicorn --host 0.0.0.0 --port 8002 server:sock
andpython client.py
raising an
Exception
produces the expected behavior.The text was updated successfully, but these errors were encountered: