部署错误请求后,Heroku Flask-SocketIO

时间:2019-05-21 14:30:47

标签: python heroku flask flask-socketio

我在使用eventlet和socketio时遇到问题

PROC文件

web: gunicorn --worker-class eventlet -w 1 server:app

Requirments.txt

Flask==0.10.1
itsdangerous==0.24
Jinja2==2.7.3
MarkupSafe==0.23
Werkzeug==0.10.4
asyncio==3.4.3
Flask-Sockets==0.2.1
Flask-SocketIO==4.0.0
eventlet==0.24.1 
gunicorn==19.9.0

服务器

from flask import Flask, render_template
from flask_socketio import SocketIO, send

import eventlet
eventlet.monkey_patch()


app = Flask(__name__)

socketio = SocketIO(app, engineio_logger=True, logger=True)


@app.route('/')
def sessions():
    return 'TEST'


@socketio.on('message')
def handle_message(message):
    print(message)
    send('CONNECTED')


@socketio.on('aComand')
def handle_message_comand(message):
    send('')


if __name__ == '__main__':
    socketio.run(app,
                 host='0.0.0.0',
                 port=5000)

当我在本地网络上使用它是可以的,但是在部署到heroku之后

192.168.1.196 - - [21/May/2019 17:05:34] code 400, message Bad request version ('\x10|g\x7f\x10Io\x81\x9e5877\x01')
192.168.1.196 - - [21/May/2019 17:05:34] "U^_YXUygqLoYt\UYYWL[WZRV\     pbzEjSuYUSXRM[][WVV
                                                                                           zcOkHU[^UXP|f}InIQ[_W\P
                                                                                                                  |gIoSWXY^\p`qEhSw[USZPO[]YUVVza}OiYpZUY]QH[W^TV\pf|EnUs\UU^WK[[]RVP      |ezImTtWUTY\L[ZZYVQ}bqHjUw]UUZVO[[YSV|a{Ii[steve@arch server]$ ^C

已经尝试了https://flask-socketio.readthedocs.io/部署部分中的所有内容

0 个答案:

没有答案