Skip to content
This repository was archived by the owner on Apr 29, 2022. It is now read-only.

How to deploy flash sockets in uwsgi CentOS ? #74

Open
ShawnChen-dev opened this issue Jul 16, 2020 · 2 comments
Open

How to deploy flash sockets in uwsgi CentOS ? #74

ShawnChen-dev opened this issue Jul 16, 2020 · 2 comments

Comments

@ShawnChen-dev
Copy link

Receive message interface exception information as follows:

environment = environ['wsgi.websocket']
KeyError: 'wsgi.websocket'

@colin-riddell
Copy link

Hi @ShawnChen-dev - you really need to give a lot more explanation about what you're trying to do specifically. What you're using, what code you've ran etc before anyone can help you.

From the very little we can see, it looks like perhaps the environ dictionary doesn't have the key "wsgi.websocket" as a literal. Though without knowing more it's hard to say what's going on.

@ShawnChen-dev
Copy link
Author

Thank you for the reminder. I did it :
`import json
from flask import Flask
from flask_sockets import Sockets

app = Flask(name)
sockets = Sockets(app)

@sockets.route('/echo')
def echo_socket(ws):
while not ws.closed:
message = ws.receive()
if message is not None:
ws.send(json.dumps({'output': message['output']}))

@app.route('/')
def hello():
return 'Hello World!'

if name == "main":
from gevent import pywsgi
from geventwebsocket.handler import WebSocketHandler

server = pywsgi.WSGIServer(('0.0.0.0', 9017), app, handler_class=WebSocketHandler)
server.serve_forever()

`

Deploy to centos7 and run this file directly. Both interfaces are normal, but running through uwsgi(uwsgi --ini flask_uwsgi.ini), HTTP interface is normal, and WS interface throws an exception
environment = environment [' wsgi.websocket ]
KeyError: ' wsgi.websocket '

uwsgi config:
[uwsgi] uid=root gid=root http-socket = 0.0.0.0:9024 chdir=/root/test-scc/scc_service master=true vhost = True workers = 2 enable-threads = True wsgi-file= run.py callable = app module=run:app logto=/var/error.log python-autoreload=1 touch-chain-reload = true uwsgi_read_timeout = 600 limit-as = 6048 processes=4 gevent= 100
This problem has bothered me for a long time. I hope my experienced friends can help me!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

2 participants