async/await websocket
See original GitHub issueI 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:
- Created 7 years ago
- Comments:7 (5 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
fixed via https://github.com/crossbario/autobahn-python/pull/759
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!