question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

async/await websocket

See original GitHub issue

I can’t use async/await in onConnect function, but it’s working with other functions like (onOpen, onMessage, onClose)

Example:


	async def test(self, x):
		return x * x

	async def onConnect(self, request):
		print("Connected.")
		res = await self.test(10)
		print(res)

Error :

Exception in callback WebSocketAdapterProtocol._consume.<locals>.process(<Future finished result=None>) at C:\Python35\lib\site-packages\autobahn\asyncio\websocket.py:109
handle: <Handle WebSocketAdapterProtocol._consume.<locals>.process(<Future finished result=None>) at C:\Python35\lib\site-packages\autobahn\asyncio\websocket.py:109>
Traceback (most recent call last):
  File "C:\Python35\lib\asyncio\events.py", line 125, in _run
    self._callback(*self._args)
  File "C:\Python35\lib\site-packages\autobahn\asyncio\websocket.py", line 113, in process
    self._dataReceived(data)
  File "C:\Python35\lib\site-packages\autobahn\websocket\protocol.py", line 1183, in _dataReceived
    self.consumeData()
  File "C:\Python35\lib\site-packages\autobahn\websocket\protocol.py", line 1212, in consumeData
    self.processHandshake()
  File "C:\Python35\lib\site-packages\autobahn\websocket\protocol.py", line 2745, in processHandshake
    self._onConnect(request)
  File "C:\Python35\lib\site-packages\autobahn\asyncio\websocket.py", line 212, in _onConnect
    self.succeedHandshake(res)
  File "C:\Python35\lib\site-packages\autobahn\websocket\protocol.py", line 2787, in succeedHandshake
    raise Exception("protocol accepted must be from the list client sent or None")
Exception: protocol accepted must be from the list client sent or None

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
oberstetcommented, Nov 27, 2016
0reactions
stan-sackcommented, Dec 8, 2016

Hey guys. You’re not catching the exception if onConnect is a coroutine. It means that I am unable to deny a connection by raising a ConnectionDeny. It would be awesome is someone could fix this!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Javascript - Using Promises on Websocket? - Stack Overflow
You create a promise when you trigger some async operation and you are waiting for the one and only one response from that...
Read more >
async-await-websockets - npm
A async/await solution to websockets. Latest version: 2.0.0, last published: 20 days ago. Start using async-await-websockets in your project ...
Read more >
An async/await WebSocket client for browsers - GitHub
Asynchronously receive data from the websocket. Resolves immediately if there is buffered, unreceived data. Otherwise, resolves with the next rececived message, ...
Read more >
Asynchronous Websockets -- a quick tutorial
Asynchronous Websockets -- a quick tutorial · Caché 2016.1+; Ability to load/compile csp pages and classes · Users to send messages; Messages sent...
Read more >
From event-driven to async/await - Medium
Let's explore a common, reusable pattern to convert an event-driven API to an async/await, task-oriented one. We can use WebSockets as ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found