Help me to deploy my chat web server on heroku


hi everyone
I try deploy a simple chat server on heroku that this app written by python and sanic and its websocket, but when I want connect to it, it raise an error:

2018-10-17T10:39:02.971038+00:00 app[web.1]: [2018-10-17 10:39:02 +0000] [9] [ERROR] Traceback (most recent call last):
2018-10-17T10:39:02.971058+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/sanic/", line 603, in handle_request
2018-10-17T10:39:02.971061+00:00 app[web.1]: response = await response
2018-10-17T10:39:02.971062+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/sanic/", line 295, in websocket_handler
2018-10-17T10:39:02.971064+00:00 app[web.1]: ws = await protocol.websocket_handshake(request,subprotocols)
2018-10-17T10:39:02.971066+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/sanic/", line 69, in websocket_handshake
2018-10-17T10:39:02.971067+00:00 app[web.1]: key = handshake.check_request(get_header)
2018-10-17T10:39:02.971069+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/websockets/", line 83, in check_request
2018-10-17T10:39:02.971070+00:00 app[web.1]: connection = parse_connection(headers.get('Connection', ''))
2018-10-17T10:39:02.971072+00:00 app[web.1]: AttributeError: 'function' object has no attribute 'get'
2018-10-17T10:39:02.971074+00:00 app[web.1]:
2018-10-17T10:39:02.971310+00:00 app[web.1]: [2018-10-17 10:39:02 +0000] - (sanic.access)[INFO][]: GET ws://  500 144

but for GET and POST methods in rest I have not any problem!
my Procfile:
web: python .
please help me what should I do?


This has nothing to do with heroku actually. This is a known issue when websockets (the package underlying websocket support in sanic) was upgraded to version 6.0. Their underlying API changed slightly.

The simple answer is to set requirements.txt to use websockets==5.0.1. Or, to build your Sanic app from the GitHub branch. This will be resolved when sanic version 18.12LTS is released.

Checkout more information: