Autobahn websocket issue while running with twistd as twisted service

#1

Hi,

I have a WebSocket server implemented using autobahn WebSocket framework with 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 when a 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()
— —
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()

My tac file main content is :


<details class='elided'>
<summary title='Show trimmed content'>&#183;&#183;&#183;</summary>

> application = service.Application("Server")
> # attach the service to its parent application
> top_service = service.MultiService()
> sqs_service = SQSListenService(factory._connected_clients)
> sqs_service.setServiceParent(top_service)
> socket_service.setServiceParent(top_service)
> top_service.setServiceParent(application)

</details>
0 Likes

#2

I have posted the same question in stack overflow and getting some replies. Adding the link of the same
: http://stackoverflow.com/questions/34157314/autobahn-websocket-issue-while-running-with-twistd-using-tac-file

···

On Tuesday, December 8, 2015 at 7:03:24 PM UTC+5:30, Muhammed Irshad wrote:

Hi,

I have a WebSocket server implemented using autobahn WebSocket framework with 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 when a 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()
— —
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()

My tac file main content is :


> application = service.Application("Server")
> # attach the service to its parent application
> top_service = service.MultiService()
> sqs_service = SQSListenService(factory._connected_clients)
> sqs_service.setServiceParent(top_service)
> socket_service.setServiceParent(top_service)
> top_service.setServiceParent(application) 

0 Likes