Skip to content
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

sanic.exceptions.InvalidUsage: Method OPTIONS not allowed for URL /socket.io/ #70

Closed
3mp3ri0r opened this issue May 11, 2018 · 14 comments
Closed
Assignees
Labels

Comments

@3mp3ri0r
Copy link

Hi all. I got issue when try to connect javascript socketio-client to python-socketio with different server port due to socketio-client request with OPTIONS method like this:

Request URL: http://localhost:8000/socket.io/?EIO=3&transport=polling&t=MDDnLi0
Request Method: OPTIONS
Status Code: 405 Method Not Allowed
Remote Address: [::1]:8000
Referrer Policy: no-referrer-when-downgrade

I've read the engine.io and I got that it doesn't add OPTIONS method in route, only GET and POST. I don't know is it a bug or I'm the one who implement it in a wrong way. Please guide me to solve this issue. Thanks.

N.B. My app locaton is http://localhost:8081.

@miguelgrinberg miguelgrinberg self-assigned this May 11, 2018
@miguelgrinberg
Copy link
Owner

Yes, sanic needs an explicit declaration of the methods that are supported. Fix coming up soon.

@3mp3ri0r
Copy link
Author

Thank you so much @miguelgrinberg. I'll wait your update.

@miguelgrinberg
Copy link
Owner

@3mp3ri0r the master branch of python-engineio now has the fix for sanic. Would you like to test it to confirm everything is working before I cut a new release?

@3mp3ri0r
Copy link
Author

Of course I'll try it. Wait.

@3mp3ri0r
Copy link
Author

Hi @miguelgrinberg, I've tried it and I got no problem with sanic invalid usage, but I got:

[2018-05-12 01:54:44 +0000] - (sanic.access)[INFO][1:7]: OPTIONS http://localhost:8000/socket.io/?EIO=3&transport=polling&t=MDI3h8H 405 16

Why my frontend apps still uable to access python-socketio? I still get 405 Method not allowed.

@miguelgrinberg
Copy link
Owner

Did you install the master branch for python-engineio, direct from GitHub? This fix has not been officially released yet.

@3mp3ri0r
Copy link
Author

Yes I'm using master branch from github by doing:
pip install git+https://github.com/miguelgrinberg/python-engineio.git

Any idea?

@miguelgrinberg
Copy link
Owner

miguelgrinberg commented May 12, 2018

Okay, sorry about that. Could you remove the package and reinstall it again from master? I think I found the problem.

@3mp3ri0r
Copy link
Author

Yay! You've solved the problem, @miguelgrinberg. Thanks. Anyway do you know why socketio transport don't upgraded from polling to websocket when connecting from other domain?

@3mp3ri0r
Copy link
Author

3mp3ri0r commented May 12, 2018

I got a gotcha. When I call asyncserver with cors_allowed_origins set, socketio-client won't upgrade from polling to websocket. This is the example:
sio = socketio.AsyncServer(async_mode='sanic', client_manager=mgr, cors_allowed_origins='*:*', logger=True)

Client will upgrade to websocket from polling when cors_allowed_origins unset like this:
sio = socketio.AsyncServer(async_mode='sanic', client_manager=mgr)

Thanks for your help @miguelgrinberg and I'm wait it published to pypi.

@miguelgrinberg
Copy link
Owner

Is *:* a valid CORS origin specification? I don't think it is, you have to use a single * to allow all domains.

@3mp3ri0r
Copy link
Author

3mp3ri0r commented May 12, 2018

Yes. I think so. I just search it and some one recomend to do it, but now I know that it was incorrect. 😂
I still waiting you pushed it to pypi.

@miguelgrinberg
Copy link
Owner

@3mp3ri0r release 2.1.1 is now in pypi. Enjoy!

@3mp3ri0r
Copy link
Author

Hurray! 🎉🎊
Thanks @miguelgrinberg.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants