0

I'm trying to get eventlet working with flask-socketio in python 2.7. Here is the bare bones code I am using:

import eventlet
from flask import Flask
from flask_socketio import SocketIO
import threading
import time

def server():
        app = Flask(__name__)
        app.config['SECRET_KEY'] = 'asdf'
        socketio = SocketIO(app, host = '0.0.0.0')
        socketio.run(app)

server_thread = threading.Thread(target = server)
server_thread.start()

while True:
    time.sleep(1)

When I run this on my laptop, this seems to work (flask-socketio uses eventlet). But when I run this on the embedded device it's intended to run on, I get the following message:

WebSocket transport not available. Install eventlet or gevent and gevent-websocket for improved performance.

There are definitely different package versions between the two systems, and I suspect that is the reason for the failure. Here are the packages on the embedded system:

click==6.7
eventlet==0.18.4
Flask==0.12.2
Flask-SocketIO==3.3.2
itsdangerous==0.24
Jinja2==2.9.6
MarkupSafe==1.0
pyserial==3.4
python-engineio==3.5.2
python-socketio==4.0.2
six==1.11.0
smbus==1.1
Werkzeug==0.12.2

Does anybody know why flask-socketio would fail to use eventlet with these versions?

Also, I don't know if it's related, but the host = '0.0.0.0' is also being ignored (on both my dev machine and the embedded machine). It's running on 127.0.0.1 always.

Any ideas?

JROS
  • 71
  • 1
  • 2
  • 11
Dave
  • 1,326
  • 2
  • 11
  • 22
  • 1
    Do you use the same method of running the application on your laptop vs. the embedded device? My guess is that the problem is in how you start the server. – Miguel Grinberg Jun 01 '19 at 18:39
  • It's the same for both: ```python test.py``` – Dave Jun 01 '19 at 18:59
  • 1
    Any reason to put the server on a thread? Eventlet and threads don't go well together. Given that you aren't doing anything in the main thread, I suggest you run the server there. – Miguel Grinberg Jun 02 '19 at 09:01
  • This is just a test application, so that's why the main thread isn't doing anything, but in the actual application, there are many threads going, all doing different things. The web server is just one of many. – Dave Jun 02 '19 at 18:05

0 Answers0