-
-
Notifications
You must be signed in to change notification settings - Fork 150
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
Invalid response when closing connection using Sanic #221
Comments
Isn't this a Sanic problem? Why is the |
Mmhh... possibly yes. Sanic only sets this attribute if the corresponding route is initialized with |
So, as I understand, Sanic wants to keep its focus on the internal websocket implementation and keep away additional complexity which may be required when handling external websocket library implementations. Then there is probably few left what your library could to in order to prevent the error message when closing a websocket connection, so I'm closing this issue for now... I don't know whether it might be worth considering #120 (comment) (i.e. raising an |
@ENT8R I'm not sure I follow this. This package does not have its own WebSocket implementation. Back in the day, Sanic did not have WebSocket support. I wrote the first implementation of it and contributed it to the project, just so that I can use it on this package. I'm not sure how things changed since then, but this package still relies on the WebSocket support provided by Sanic. This is why I think it is a Sanic bug that the I'll take a quick look to see if I can figure out what the problem is, or if things changed considerably in the Sanic side since I've done the initial work on WebSocket support. |
Just to chime in here, I have also experienced this error while trying to use python-socketio with Sanic. In my case the error seems to occur when the client tries to upgrade the connection to ws, though, rather than when it tries to close the connection. I'm happy to provide more details if that would be helpful. I can also post in that Sanic bug, but they seemed a lot less interested in looking at it, as mentioned. |
@seanmkauffman I looked at the current state of their WebSocket support. They've changed an important design aspect and that makes it impossible (or at least hard) to address this error. Basically a route in Sanic has to be either HTTP or WebSocket, it can't be both. On a WebSocket route, they set The Socket.IO protocol uses the same endpoint for HTTP and WebSocket connections, so it cannot be adapted to work in the way Sanic currently wants. Since they have no interest in addressing this use case, this will have to stay like this. |
@miguelgrinberg Thanks for the update! I will try aiohttp then. |
I'm currently experiencing an issue similar but distinct to #120 when using Sanic as a framework together with Socket.IO
In case the request has been upgraded to a websocket connection, and this connection is closed by the client, the asynchronous socket
_websocket_handler()
method returns no value.Sanic now checks whether the response returned by the handler is an instance of Sanic's
BaseHTTPResponse
, which is not the case, so no response is send to the client. Instead Sanic applies an additional check by checking whetherhandler.is_websocket
is set, but this also fails as this property seems to be set only when using the internal websocket implementation of Sanic andhandler
is thehandle_request
method of Engine.IOThe affected code part can be found here: https://github.com/sanic-org/sanic/blob/main/sanic/app.py#L724-L740
A possible solution I could think of is replacing
python-engineio/engineio/async_drivers/sanic.py
Lines 19 to 20 in 845fc62
with the following snippet according to PEP-232 even though I don't know if this is the most elegant way to solve this...
The text was updated successfully, but these errors were encountered: