Autobahn with asyncio - unable to create connection for URL with paths
I am trying to connect to two WebSockets (WebSocket A with URI wss: //domainA.com and WebSocket B with URI wss: //domainB.com/path) using Autobahn running on asyncio as described in Autobahn docs .
I created a WebSocketClientProtocol file, for example:
from autobahn.asyncio.websocket import WebSocketClientProtocol
class ClientProtocol(WebSocketClientProtocol):
def onConnect(self, response):
print("Connected to Server: {}".format(response.peer))
and connecting to WebSocket using asyncio connection:
from autobahn.asyncio.websocket import WebSocketClientFactory
import asyncio
factory = WebSocketClientFactory()
factory.protocol = ClientProtocol
loop = asyncio.get_event_loop()
coro = loop.create_connection(factory, 'domainA.com', 80)
loop.run_until_complete(coro)
loop.run_forever()
loop.close()
I can connect to WebSocket A, but connecting to WebSocket B by replacing domainA.com
with domainB.com/path
results in an errorgaierror: [Errno 8] nodename nor servname provided, or not known.
I know WebSocket B is working, since I can connect to it using another library. Moreover, replacing domainB.com/path
only by domainB.com
, we obtainconnection was closed uncleanly (WebSocket connection upgrade failed (301 - MovedPermanently))
source to share
No one has answered this question yet
Check out similar questions: