I have the following JS code that works great to connect to a socket via the socketio client library:
userApi = 'userapiaccesfskdglk';
userAccess = 'useaccesfjkasdfdlkf2';
var axios = require('axios');
var socket = require('socket.io-client')('wss://test-meownow12345.com:4566');
socket.emit('Authenticate', {api: userApi, access: userAccess});
socket.on('Party', function(party) {
console.log('party', party)
})
These are not the actual userApi, userAccess, or urls used, but using them still gets the same point across.
This is what i have in python, that to me looks like an exact port but is not working:
from socketIO_client import SocketIO, LoggingNamespace
import logging
logging.basicConfig(level=logging.DEBUG)
def on_party():
print('connect')
userApi = 'userapiaccesfskdglk'
userAccess = 'useaccesfjkasdfdlkf2'
with SocketIO('wss://test-meownow12345.com', 4566, LoggingNamespace) as socketIO:
socketIO.emit('Authenticate', {'api': userApi, 'access': userAccess})
socketIO.on('Party', on_party)
It seems like it is equivalent but it is clearly not as the code cannot get past the following line that opens the socket.io connection:
with SocketIO('wss://test-meownow12345.com', 4566, LoggingNamespace) as socketIO:
In my console it prints out the following log errors that just repeat:
DEBUG:urllib3.connectionpool:Starting new HTTP connection (1): wss
WARNING:socketIO-client:wss:4566//test-meownow12345.com/socket.io [engine.io waiting for connection] HTTPConnectionPool(host='wss', port=4566): Max retries exceeded with url: //test-meownow12345.com/socket.io/?EIO=3&transport=polling&t=1523668232386-0 (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x105000278>: Failed to establish a new connection: [Errno 8] nodename nor servname provided, or not known',))
I'm not really sure what this means.
I have tried changing the line giving this message and drop the 'wss://' part to make it:
with SocketIO('test-meownow12345.com', 4566, LoggingNamespace) as socketIO:
but this still fails, albeit with a new message in the logs that repeats:
DEBUG:urllib3.connectionpool:Starting new HTTP connection (1): test-meownow12345.com
WARNING:socketIO-client:test-meownow12345.com:4566/socket.io [engine.io waiting for connection] ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response',))
DEBUG:urllib3.connectionpool:Starting new HTTP connection (2): test-meownow12345.com
DEBUG:urllib3.connectionpool:Starting new HTTP connection (3): test-meownow12345.com
Any help is really appreciated, this is quite a frustrating problem.
from Trying to port my socketio client from js to python but it is not working
No comments:
Post a Comment