-
-
Notifications
You must be signed in to change notification settings - Fork 161
Strip root_path to simplify mounting as ASGI sub app #345
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
Conversation
|
I don't think this is the right change for this package. The idea of The way I recommend that you set up your applications is to use my |
|
Thanks for reviewing my PR and for your insights on the I came across a discussion in the ASGI spec that elaborates on I realize now that this adjustment could introduce a breaking change, for which I should have initially marked the PR as a draft and highlighted the potential impact more clearly. I'm eager to discuss the path towards ASGI spec compatibility and whether it's a direction you'd consider exploring together, ensuring we provide thorough documentation for a smooth transition. Looking forward to your feedback on pursuing this alignment with the ASGI spec. |
|
As I said above, I don't see the current You should consider that the ASGIApp class is overkill in the way that you are using it. You are relying on Starlette to do the routing, so ASGIApp doing routing after Starlette makes no sense at all. For your use case, you need a much simpler ASGIApp-like class that does not do any routing and just sends all traffic to the Socket.IO server no questions asked. Thinking over this, maybe the best option is to add an option that implements what I just said. For example, setting |
That is a wonderful idea. I just altered this pull request accordingly. I thought its most consistent if the parameters An alternative could be to split the two variants into separate classes. For example |
|
Merged after fixing the remaining linter issues. Thank you so much! |
As an outcome of Kludex/starlette#2413 with newer Starlette versions we now have to provide the full path as
engineio_pathas done in the following example (viasocketio.ASGIApp(socketio_server=sio, socketio_path='/ws/socket.io'):That works as long as the app is not itself mounted as a sub app like this:
The above code fails because the frontend tries to connect to
/sub/ws/socket.iobut engineio simply checks if thescope['path']starts withself.engineio_path.This pull request fixes this by making python-engineio aware of ASGIs
scope['root_path']. It strips the root path fromscope['path']before checking whether it matchesself.engineio_path. This allows us to provide the relativesocketio_path(which is then passed to engineio asengineio_path:The issue came up in zauberzeug/nicegui#2515 and zauberzeug/nicegui#2468. It should be fixed in python-enginio in my opinion to better support "ASGI sub app mounting" for everyone using python-engineio.