Autobahn websocket issue while running with twistd using tac file

穿精又带淫゛_ 提交于 2019-12-23 13:11:42

问题


I have a WebSocket server implemented using autobahn WebSocket framework using twisted. WebSocket server runs fine when the program ran with python. But if I run this using twistd server runner by creating tac file as twisted service, I get the following error in server while any client try to establish connection and the handshake is failing.

2015-12-08 07:17:56,022 - CRITICAL - twisted.publishToNewObserver() 154 Unhandled Error Traceback (most recent call last): File "/opt/nrgi-ws/nrgi-ws-virtual-env/local/lib/python2.7/site-packages/twisted/python/log.py", line 84, in callWithContext return context.call({ILogContext: newCtx}, func, *args, **kw) File "/opt/nrgi-ws/nrgi-ws-virtual-env/local/lib/python2.7/site-packages/twisted/python/context.py", line 118, in callWithContext return self.currentContext().callWithContext(ctx, func, *args, **kw) File "/opt/nrgi-ws/nrgi-ws-virtual-env/local/lib/python2.7/site-packages/twisted/python/context.py", line 81, in callWithContext return func(*args,**kw) File "/opt/nrgi-ws/nrgi-ws-virtual-env/local/lib/python2.7/site-packages/twisted/internet/posixbase.py", line 597, in _doReadOrWrite why = selectable.doRead() --- <exception caught here> --- File "/opt/nrgi-ws/nrgi-ws-virtual-env/local/lib/python2.7/site-packages/twisted/internet/tcp.py", line 1067, in doRead protocol = self.factory.buildProtocol(self._buildAddr(addr)) File "/opt/nrgi-ws/nrgi-ws-virtual-env/local/lib/python2.7/site-packages/twisted/internet/protocol.py", line 135, in buildProtocol p = self.protocol() File "/opt/nrgi-ws/nrgi-ws-virtual-env/local/lib/python2.7/site-packages/autobahn/websocket/protocol.py", line 665, in __init__ self.is_closed = txaio.create_future() File "/opt/nrgi-ws/nrgi-ws-virtual-env/local/lib/python2.7/site-packages/txaio/_unframework.py", line 43, in _throw_usage_error "To use txaio, you must first select a framework " exceptions.RuntimeError: To use txaio, you must first select a framework with .use_twisted() or .use_txaio()


回答1:


I found the same problem today. You should downgrade txaio to version 1.1.0

Here is my pip list autobahn (0.10.9) autobahntestsuite (0.7.3) Twisted (15.4.0) txaio (1.1.0) zope.interface (4.1.3)




回答2:


This issue was not happening in my Ubuntu system. I was having this issue in ec2 instance with Machine Image Amazon Linux AMI. Seems txaio couldn’t detect the available twisted framework. Another fix other than mentioned above by @helder.vasc is to specify the framework as twisted explicitly. Adding this below in tac file solved the issue :

import txaio txaio.use_twisted()

Note sure about weather this is the perfect way to tackle this issue though.




回答3:


Can you try with Autobahn master? This should be fixed there, but there isn't yet a release containing the fix (dd1cff8f9480a125e510108482bfaf5b9eedc916).

You can install master like this: pip install https://github.com/crossbario/autobahn-python/archive/master.zip




回答4:


AutobahnTestSuite was just updated and corrects this problem:

autobahn (0.10.9) autobahntestsuite (0.7.4) Twisted (15.5.0) txaio (2.1.0)



来源:https://stackoverflow.com/questions/34157314/autobahn-websocket-issue-while-running-with-twistd-using-tac-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!