Hi @miguelgrinberg
Thanks for your awesome library
It seems that I can't get it to work with chinese Character string
but The Flask development server is normal
my environment variable
nginx eventlet
@yuzhixin when you say that you can't get it to work, what do you mean exactly? Do you get an error? If you do, please past the complete stack trace here.
@miguelgrinberg Thanks for your reply
As you see the server management console is quiet when the input is chinese Character string
http://i4.piimg.com/4851/a596546101a31bb4.png
http://i1.piimg.com/4851/d835c1b0d236ac16.png
my nginx conf
server {
listen 80;
server_name localhost.localhost;
charset utf-8;
access_log /mydata/www/develop/cy_crm/nginx.log;
error_log /mydata/www/develop/cy_crm/nginx.error.log;
location / {
proxy_pass http://127.0.0.1:8214;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location /static/ {
alias /mydata/www/develop/cy_crm/static/;
}
location /media/ {
alias /mydata/data/develop/cy_crm/upload/;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
Does it work when you connect directly to the server at port 8214?
Directly to the server at port 8214 is work。
Is problem of nginx?
I'm not sure, I tried here without nginx and everything works well also. You need to debug the request. You can look in the nginx logs to see if the request with Chinese characters was received. Then you can look in the Flask app for the same thing.
Thank you for your help
This modified command is work.
gunicorn -k geventwebsocket.gunicorn.workers.GeventWebSocketWorker -w 1 module:app
That's kind of unrelated I think. That is used to enable websocket when using gevent. It's required regardless of having nginx or not. But in any case, glad you have resolved the issue.
@miguelgrinberg Sometimes I got this
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/gevent/pywsgi.py", line 884, in handle_one_response
self.run_application()
File "/usr/local/lib/python2.7/dist-packages/geventwebsocket/handler.py", line 76, in run_application
self.run_websocket()
File "/usr/local/lib/python2.7/dist-packages/geventwebsocket/handler.py", line 52, in run_websocket
self.application(self.environ, lambda s, h, e=None: [])
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1836, in call
return self.wsgi_app(environ, start_response)
File "/usr/local/lib/python2.7/dist-packages/Flask_SocketIO-2.2-py2.7.egg/flask_socketio/init.py", line 37, in call
start_response)
File "/usr/local/lib/python2.7/dist-packages/python_engineio-0.9.0-py2.7.egg/engineio/middleware.py", line 47, in call
return self.engineio_app.handle_request(environ, start_response)
File "/usr/local/lib/python2.7/dist-packages/python_socketio-1.2-py2.7.egg/socketio/server.py", line 303, in handle_request
return self.eio.handle_request(environ, start_response)
File "/usr/local/lib/python2.7/dist-packages/python_engineio-0.9.0-py2.7.egg/engineio/server.py", line 226, in handle_request
environ, start_response)
File "/usr/local/lib/python2.7/dist-packages/python_engineio-0.9.0-py2.7.egg/engineio/socket.py", line 79, in handle_get_request
start_response)
File "/usr/local/lib/python2.7/dist-packages/python_engineio-0.9.0-py2.7.egg/engineio/socket.py", line 118, in _upgrade_websocket
return ws(environ, start_response)
File "/usr/local/lib/python2.7/dist-packages/python_engineio-0.9.0-py2.7.egg/engineio/async_gevent.py", line 43, in __call__
return self.app(self)
File "/usr/local/lib/python2.7/dist-packages/python_engineio-0.9.0-py2.7.egg/engineio/socket.py", line 180, in _websocket_handler
self.receive(pkt)
File "/usr/local/lib/python2.7/dist-packages/python_engineio-0.9.0-py2.7.egg/engineio/socket.py", line 48, in receive
self.server._trigger_event('message', self.sid, pkt.data)
File "/usr/local/lib/python2.7/dist-packages/python_engineio-0.9.0-py2.7.egg/engineio/server.py", line 330, in _trigger_event
return self.handlersevent
File "/usr/local/lib/python2.7/dist-packages/python_socketio-1.2-py2.7.egg/socketio/server.py", line 429, in _handle_eio_message
self._handle_event(sid, pkt.namespace, pkt.id, pkt.data)
File "/usr/local/lib/python2.7/dist-packages/python_socketio-1.2-py2.7.egg/socketio/server.py", line 371, in _handle_event
r = self._trigger_event(data[0], namespace, sid, _data[1:])
File "/usr/local/lib/python2.7/dist-packages/python_socketio-1.2-py2.7.egg/socketio/server.py", line 397, in _trigger_event
return self.handlers[namespace][event](_args)
File "/usr/local/lib/python2.7/dist-packages/Flask_SocketIO-2.2-py2.7.egg/flask_socketio/__init__.py", line 177, in _handler
app = self.server.environ[sid]['flask.app']
KeyError: '0ed2536300334dd39968dadb69a70322'
{'GATEWAY_INTERFACE': 'CGI/1.1',
'HTTP_CACHE_CONTROL': 'no-cache',
'HTTP_CONNECTION': 'Upgrade',
'HTTP_COOKIE': 'io=0ed2536300334dd39968dadb69a70322; session=eyJuYW1lIjoiZGRoZGgiLCJzaWQiOnsiIGIiOiJNakF4TmpBNE1UWXhPVFEwTVRRM01UTTBOemczTkRRM056Z3hNZz09In19.CpSOIg.IGho3fFSIn0yMEP3rwcy8wWUM9g',
'HTTP_HOST': 'crm.yihe.ren',
'HTTP_ORIGIN': 'http://crm.yihe.ren',
'HTTP_PRAGMA': 'no-cache',
'HTTP_SEC_WEBSOCKET_EXTENSIONS': 'permessage-deflate; client_max_window_bits, x-webkit-deflate-frame',
'HTTP_SEC_WEBSOCKET_KEY': 'NsFGJdQXjCBF4oVT9nx3Ow==',
'HTTP_SEC_WEBSOCKET_VERSION': '13',
'HTTP_UPGRADE': 'websocket',
'HTTP_USER_AGENT': 'Mozilla/5.0 (Linux; Android 4.4.4; MI 3 Build/KTU84P) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/37.0.0.0 Mobile MQQBrowser/6.2 TBS/036555 Safari/537.36 MicroMessenger/6.3.22.821 NetType/WIFI Language/zh_CN',
'HTTP_X_FORWARDED_FOR': '123.116.134.163',
'HTTP_X_REAL_IP': '123.116.134.163',
'PATH_INFO': '/socket.io/',
'QUERY_STRING': 'EIO=3&transport=websocket&sid=0ed2536300334dd39968dadb69a70322',
'REMOTE_ADDR': '127.0.0.1',
'REMOTE_PORT': '33157',
'REQUEST_METHOD': 'GET',
'SCRIPT_NAME': '',
'SERVER_NAME': 'localhost',
'SERVER_PORT': '8214',
'SERVER_PROTOCOL': 'HTTP/1.1',
'SERVER_SOFTWARE': 'gevent/1.1.2 gunicorn/17.5',
'flask.app':
'wsgi.errors':
'wsgi.input':
'wsgi.multiprocess': False,
'wsgi.multithread': False,
'wsgi.run_once': False,
'wsgi.url_scheme': 'http',
'wsgi.version': (1, 0),
'wsgi.websocket': None,
'wsgi.websocket_version': '13'}
What version of Flask-SocketIO are you using? This error was fixed in release 2.4, try upgrading.
Most helpful comment
What version of Flask-SocketIO are you using? This error was fixed in release 2.4, try upgrading.