Issue
I'm trying to build flask websocket server with python 3.5. server works in my macbook and ubuntu 16.04 desktop server at my home, but it doesn't work same Os (ubuntu 16.04) desktop at my job.
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/1.3.5/socket.io.min.js"></script>
var socket =
io.connect(location.protocol +'//'+document.domain+':'+location.port+namespace);
when I run my server use macbook and ubuntu 16.04 server at my home, printed log is like it
WebSocket transport not available. Install eventlet or gevent and gevent-websocket for improved performance.
* Serving Flask app "SDPS" (lazy loading)
* Environment: production
WARNING: Do not use the development server in a production environment.
Use a production WSGI server instead.
* Debug mode: on
* Running on http://127.0.0.1:9890/ (Press CTRL+C to quit)
* Restarting with stat
WebSocket transport not available. Install eventlet or gevent and gevent-websocket for improved performance.
* Debugger is active!
* Debugger PIN: 327-937-508
and my server works.
But I run same code at server in my job with Ubuntu, printed log is like it.
* Restarting with stat
* Debugger is active!
* Debugger PIN: 379-138-971
(16863) wsgi starting up on http://127.0.0.1:8000
(16863) accepted ('127.0.0.1', 42058)
when i open web page, then error log appear.
127.0.0.1 - - [10/Dec/2018 21:50:07] "GET /socket.io/?EIO=3&transport=polling&t=1544446207144-8 HTTP/1.1" 404 366 0.002325
Why are there different running log message at terminal?
I think wsgi makes some problems. Even flask-socketio git example doesn't work at Desktop server in my job. Why are these error appear though same code and same Ubuntu 16.04 Os?
macbook, ubuntu 16.04(home) -> work
ubuntu 16.04(job) -> doesn't work
Solution
Do you use the same Socket.IO
version?
As far as I know flask-socketio
supports socketio-1.x
while most of javascript clients use socketio-2.x
which causes a lot of errors in encoding etc. Can you double-check that the backend and frontend are in the same socketio
version?
Answered By - Dimitrios Mavrommatis
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.