I have a current flask program that was using this command on gunicorn:
gunicorn --worker-class eventlet --workers 1 --bind 0.0.0.0:4000 -m 007 --log-level=debug wsgi:application
In order to run flask sockets i changed this to
gunicorn -k flask_sockets.worker --access-logfile gunicorn_access.log --error-logfile gunicorn_error.log --log-level=debug wsgi:application
with the following code (i'm intending on sending jpeg stream through websocket, hence the camera Object):
HTTP_SERVER_PORT = 5000
camera = Camera(app, './get.py', 960, 720)
socket = SocketLocal(app, camera)
thread = None
@sockets.route('/data')
def echo(ws):
app.logger.info("Connected accepted")
has_seen_media = False
#send through to client
while not ws.closed:
gevent.sleep(0.1)
try:
data = gevent.with_timeout(0.1, ws.receive, timeout_value="")
if data is None:
raise Exception("socket closed")
except:
break
message = ws.receive()
if message is None:
app.logger.info("No message received...")
continue
data = loads("message")
if data['event'] == "connected":
app.logger.info("Connected Message Received: {}".format(message))
if data['event'] == "start":
app.logger.info("Start Message received: {}".format(message))
if data['event'] == "media":
global socket
global thread
socket.ws = ws
thread = threading.Thread(target=socket._camerathread)
thread.start()
if data['event'] == 'closed':
app.logger.info("Closed Message received: {}".format(message))
break
thread = None
app.logger.info("Connection closed")
if __name__== "__main__":
#app.run(host='0.0.0.0', threaded=True)
config['thermal']['url'] = url_for('video_feed')
from gevent import pywsgi
from geventwebsocket.handler import WebSocketHandler
server = pywsgi.WSGIServer(('', HTTP_SERVER_PORT), app, handler_class=WebSocketHandler)
server.serve_forever()
my gunicorn_access log reports that no connection is being made from this end.
im trying to connect to ws://ip:5000/data with OKHttp3 Client.
I have a current flask program that was using this command on gunicorn: gunicorn --worker-class eventlet --workers 1 --bind 0.0.0.0:4000 -m 007 --log-level=debug wsgi:application
In order to run flask sockets i changed this to gunicorn -k flask_sockets.worker --access-logfile gunicorn_access.log --error-logfile gunicorn_error.log --log-level=debug wsgi:application
with the following code (i'm intending on sending jpeg stream through websocket, hence the camera Object):
my gunicorn_access log reports that no connection is being made from this end. im trying to connect to ws://ip:5000/data with OKHttp3 Client.