siopaoman
siopaoman

Reputation: 1793

GET /socket.io/?EIO=3&transport=polling&t=MniHjPM HTTP/1.1

I have a simple Flask chat application that I am testing out coming from a tutorial. Supposedly I just need to run it using the "python app.py" command but when I access it via http://localhost:5000 i get a continuous message of this:

Console

I was hoping to get 200. I have Flask, Flask-SocketIO, and eventlet already installed. Any idea that can point me in the right direction? Thank you.

Upvotes: 5

Views: 8620

Answers (2)

jlee7
jlee7

Reputation: 146

The code from the Flask-SocketIO documentation also produced the same error for me. However this example code did not (also in debug mode): https://github.com/miguelgrinberg/Flask-SocketIO

In both, the fix above is not included. Changing the HTML script tags helped.

From:

<script src="//cdnjs.cloudflare.com/ajax/libs/socket.io/2.2.0/socket.io.js" integrity="sha256-yr4fRk/GU1ehYJPAs8P4JlTgu0Hdsp4ZKrx8bDEDC3I=" crossorigin="anonymous"></script>

To:

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js" integrity="sha512-bLT0Qm9VnAYZDflyKcBaQ2gg0hSYNQrJ8RilYldYQ1FxQYoCLtUjuuRuZo+fjqhx/qtq/1itJ0C2ejDxltZVFg==" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/3.0.4/socket.io.js" integrity="sha512-aMGMvNYu8Ue4G+fHa359jcPb1u+ytAF+P2SCb+PxrjCdO3n3ZTxJ30zuH39rimUggmTwmh2u7wvQsDTHESnmfQ==" crossorigin="anonymous"></script>

Upvotes: 2

Mamun
Mamun

Reputation: 496

The current release of Flask-SocketIO has stricter requirements with regards to cross-origin requests. adding cors_allowed_origins='https://localhost will resolve the error.
i.e. SocketIO(app,cors_allowed_origins="http://localhost") or
SocketIO(app,cors_allowed_origins="*") hopefully this work.

Upvotes: 13

Related Questions