-
-
Notifications
You must be signed in to change notification settings - Fork 890
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
flask socketio 400 (BAD REQUEST) #287
Comments
What is your web browser? Or in other words, how do you start the Flask-SocketIO server? |
I’m using chrome Version 51.0.2704.103 (64-bit). I just access my index.html through chrome |
How do you run the server? |
I just use the linux command: flask run |
Read the docs. Flask-SocketIO uses a different method for server start up. |
what do you mean? can you point out where in the docs? in my python code, I have: if name == "main": |
You need to run the script, so that I think the docs could use some more detail here that is specifically addressed to Flask's 0.11 and its new CLI. |
ok, I got it, now it works. Thanks! |
@BoYanSTKO what did you change to make it work? |
I'm starting the server with gunicorn, having the same issue: |
@akapit I just replied to your comment on the blog. Your 400 error is caused by the cross-origin policy. Your browser is reporting an origin that is not supported by the server. You may want to write a new issue and indicate how you initialize your Socket.IO server (and in particular if you set any of its CORS options), and if/how you configure CORS for your Flask application. |
@ miguelgrinberg thanks for your answer, I've just wrote a new issue with those details. Let me know if I can provide anything else. Gracias! |
@miguelgrinberg Hola Miguel, estoy teniendo el mismo problema. Estoy utilizando el websocket para retransmitir tweets, y de vez en cuanto me salta en error 400 bad request. Una vez ser reconecta, la retransmisión sigue pero se me repiten los tweets (por poner un ejemplo de las consecuencias). Sabes cómo puede solucionarse? Gracias de antemano! (English: I´m having the same issue!. I´m using the websocket for streaming tweets in the web app, and from time to time 400 bad request shows up, causing two identical tweets to be retransmited (as an example of the issues). Do you know how could be fixed? thanks! if name == 'main': |
@Alexcorrochano los errors 400 pueden ocurrir por muchas razones. Tendrias que averiguar cual es el problema en tu caso. Si activas los logs quiza sea mas claro. |
I'm trying to use flask socketio to retrieve some live tweets and currently I'm playing around with the socketio to see how it works. But in my test, I get 400 (BAD REQUEST) from time to time. I'm wondering what is the issue.
here's the error sample:
socket.io.js:3511 POST http://127.0.0.1:5000/socket.io/?EIO=3&transport=polling&t=LOMYW0D&sid=c81baa220764437184a14366357c6d3d 400 (BAD REQUEST)Request.create @ socket.io.js:3511Request @ socket.io.js:3424XHR.request @ socket.io.js:3352XHR.doWrite @ socket.io.js:3365(anonymous function) @ socket.io.js:3884(anonymous function) @ socket.io.js:4747proxy @ socket.io.js:1197(anonymous function) @ socket.io.js:4762(anonymous function) @ socket.io.js:4742exports.encodePacket @ socket.io.js:4541encodeOne @ socket.io.js:4741eachWithIndex @ socket.io.js:4760map @ socket.io.js:4767exports.encodePayload @ socket.io.js:4746Polling.write @ socket.io.js:3883Transport.send @ socket.io.js:2912Socket.flush @ socket.io.js:2623Socket.sendPacket @ socket.io.js:2683Socket.ping @ socket.io.js:2587(anonymous function) @ socket.io.js:2574 socket.io.js:3511 GET http://127.0.0.1:5000/socket.io/?EIO=3&transport=polling&t=LOMYPYb&sid=c81baa220764437184a14366357c6d3d 400 (BAD REQUEST)Request.create @ socket.io.js:3511Request @ socket.io.js:3424XHR.request @ socket.io.js:3352XHR.doPoll @ socket.io.js:3382Polling.poll @ socket.io.js:3795Polling.onData @ socket.io.js:3834(anonymous function) @ socket.io.js:3385Emitter.emit @ socket.io.js:4389Request.onData @ socket.io.js:3546Request.onLoad @ socket.io.js:3627xhr.onreadystatechange @ socket.io.js:3499 socket.io.js:3511 POST http://127.0.0.1:5000/socket.io/?EIO=3&transport=polling&t=LOMYeOF&sid=c81baa220764437184a14366357c6d3d 400 (BAD REQUEST)
my server side code (python flask):
my client side code:
These are the initial output when I start the index.html page:
but after like 30 second or so, it began to have the previous 400 bad request error, followed by the following result:
Then after like 30 seconds, it does the bad request and the result all over again. where am I doing wrong? any help will be appreciated.
for the client side, I'm using socketio js 1.4.5
for python:
Flask-SocketIO==2.5
python-engineio==0.9.2
The text was updated successfully, but these errors were encountered: