Error with ASGI / hypercorn causing participants to get stuck on wait-pages

1,089 views
Skip to first unread message

Alex D

unread,
Oct 14, 2021, 1:13:04 PM10/14/21
to oTree help & discussion
Dear all,

I am running a otree 3.3.11 experiment (due to compatibility with some older code) and am encountering some strange behaviour, where participants sometimes get stuck on wait pages. They are not advanced after all members of the group arrive, however reloading the page client-side forwards them to the appropriate page. Thus they somehow seem to get disconnected from the server.

The logs in the server report issues such as:

Error in ASGI Framework
Traceback (most recent call last):
File "/Users/alex/anaconda3/envs/otree_timedemand/lib/python3.7/site-packages/hypercorn_otree/asyncio/spawn_app.py", line 14, in _handle
await invoke_asgi(app, scope, receive, send)
File "/Users/alex/anaconda3/envs/otree_timedemand/lib/python3.7/site-packages/hypercorn_otree/utils.py", line 199, in invoke_asgi
await asgi_instance(receive, send)
File "/Users/alex/anaconda3/envs/otree_timedemand/lib/python3.7/site-packages/channels/sessions.py", line 183, in __call__
return await self.inner(receive, self.send)
File "/Users/alex/anaconda3/envs/otree_timedemand/lib/python3.7/site-packages/channels/middleware.py", line 41, in coroutine_call
await inner_instance(receive, send)
File "/Users/alex/anaconda3/envs/otree_timedemand/lib/python3.7/site-packages/channels/consumer.py", line 59, in __call__
[receive, self.channel_receive], self.dispatch
File "/Users/alex/anaconda3/envs/otree_timedemand/lib/python3.7/site-packages/channels/utils.py", line 51, in await_many_dispatch
await dispatch(result)
File "/Users/alex/anaconda3/envs/otree_timedemand/lib/python3.7/site-packages/channels/consumer.py", line 75, in dispatch
raise ValueError("No handler for message type %s" % message["type"])
ValueError: No handler for message type wait_page_ready

or:

ERROR Task exception was never retrieved
future: <Task finished coro=<WSStream._cancel_due_to_timeout() done, defined at /app/.heroku/python/lib/python3.7/site-packages/hypercorn_otree/protocol/ws_stream.py:351> exception=LocalProtocolError('Connection cannot be closed in state ConnectionState.LOCAL_CLOSING')>
Traceback (most recent call last):
File "/app/.heroku/python/lib/python3.7/site-packages/hypercorn_otree/protocol/ws_stream.py", line 352, in _cancel_due_to_timeout
await self._send_wsproto_event(CloseConnection(code=CloseReason.ABNORMAL_CLOSURE))
File "/app/.heroku/python/lib/python3.7/site-packages/hypercorn_otree/protocol/ws_stream.py", line 320, in _send_wsproto_event
data = self.connection.send(event)
File "/app/.heroku/python/lib/python3.7/site-packages/wsproto/connection.py", line 100, in send
"Connection cannot be closed in state %s" % self.state
wsproto.utilities.LocalProtocolError: Connection cannot be closed in state ConnectionState.LOCAL_CLOSING


This leads me to belief that this is some error with ASGI / hypercorn / Django Channels. Any Idea what the concrete issue might be and on how I might be able to fix this?

Package Version
-------------------- --------
asgiref 3.2.7
colorama 0.4.1
dj-database-url 0.5.0
Django 2.2.12
django-vanilla-views 1.0.6
h11 0.12.0
h2 4.0.0
hpack 4.0.0
hyperframe 6.0.1
otree 3.3.11
pip 20.1.1
priority 2.0.0
psycopg2 2.8.6
pytz 2019.2
setuptools 47.1.1
sqlparse 0.4.2
termcolor 1.1.0
toml 0.10.2
typing-extensions 3.10.0.2
wheel 0.34.2
whitenoise 4.1.3
wsproto 1.0.0


Chris @ oTree

unread,
Oct 14, 2021, 4:09:58 PM10/14/21
to oTree help & discussion
Hi, I'm not sure why these errors would be happening, especially the first. I will give it some more thought.
Alternatively, if you send me your project (run 'otree zip'), I can try upgrading it to oTree 5.

Alex D

unread,
Oct 15, 2021, 4:03:44 AM10/15/21
to oTree help & discussion
Hi Chris,

thanks for offering to look into it. A few further remarks about the (somewhat messy and uncoordinated code - sorry about that), that might help you understand what might be wrong with what I have done.
I sent you the otree.zip via email to your otree.org email.

 - I am using a modified chat widget, as I need to custom style it and to introduce a message every round, that conveys some information in the chat. 
 - I am using the otree admin chat from https://github.com/Furuneko/otree_admin_chat 
 - I am using a custom model to implement punishment fields (when applicable) (largely based on P. Chapkovski's implementation of the FGF PGG with punishment.)

Further info: the app is running on a dokku instance (basically a open source Heroku clone) or rather a docker container, but I don't think that this is the issue. Thus I think the problem might be based on my code somewhere. However this is the reason why I want to stay on 3.3.X as changing to 5.X would break the functionality of the admin chat and using 5.X. with a custom papercups instance is something I would want to avoid. 

Again, thanks for looking into it. 
Alex
Reply all
Reply to author
Forward
0 new messages