We have a python code:
vToken = GetToken()
ListenPort = 'http://180.13.1.245:3013'
sio = socketio.AsyncClient()
loop = asyncio.get_event_loop()
start_timer = None
async def send_ping():
global start_timer
start_timer = time.time()
await sio.emit('ping_from_client')
@sio.event
async def connect():
print('connected to server')
await send_ping()
@sio.event
async def pong_from_server():
global start_timer
latency = time.time() - start_timer
print('latency is {0:.2f} ms'.format(latency * 1000))
await sio.sleep(1)
await send_ping()
async def start_server():
await sio.connect(ListenPort)
await sio.emit('report-client-register', data={'token': vToken, 'channelRole': 'client'})
sio.on('report-client-rejection', {'token': vToken})
sio.on('report-client-rooms', {'token': vToken})
sio.on('push-broadcast-register', {'token': vToken})
if __name__ == '__main__':
loop.run_until_complete(start_server())
and Log file:
08/24/2020 02:50:17 PM Starting new HTTPS connection (1): cajeros.frontusuarios_st.monitorizacion.santander.pre.corp:443
08/24/2020 02:50:17 PM https://cajeros.frontusuarios_st.monitorizacion.santander.pre.corp:443 "POST /ws/geplus/v1/d/login HTTP/1.1" 200 249
08/24/2020 02:50:17 PM Using selector: SelectSelector
08/24/2020 02:50:17 PM Attempting polling connection to http://180.13.1.245:3013/socket.io/?transport=polling&EIO=3
08/24/2020 02:50:17 PM Polling connection accepted with {'sid': 'vPRGLKw5nI-EkW7uAAAD', 'upgrades': ['websocket'], 'pingInterval': 25000, 'pingTimeout': 5000}
08/24/2020 02:50:17 PM Engine.IO connection established
08/24/2020 02:50:17 PM Received packet MESSAGE data 0
08/24/2020 02:50:17 PM Attempting WebSocket upgrade to ws://180.13.1.245:3013/socket.io/?transport=websocket&EIO=3
08/24/2020 02:50:17 PM Namespace / is connected
08/24/2020 02:50:17 PM Emitting event "ping_from_client" [/]
08/24/2020 02:50:17 PM Sending packet MESSAGE data 2["ping_from_client"]
08/24/2020 02:50:17 PM WebSocket upgrade was successful
08/24/2020 02:50:17 PM Emitting event "report-client-register" [/]
08/24/2020 02:50:17 PM Sending packet MESSAGE data 2["report-client-register",{"token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuaWNrIjoiQWxiZXJ0byIsImlhdCI6MTU5ODI3MzQ4NSwiZXhwIjoxNTk4MzU5ODg1fQ.7obwM0R64eQdAwWUTQFyLitEHwwv7XXzzn4SvR0hgUc","channelRole":"client"}]
08/24/2020 02:50:17 PM Emitting event "report-client-register" [/]
08/24/2020 02:50:17 PM Sending packet MESSAGE data 2["report-client-register",{"token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuaWNrIjoiQWxiZXJ0byIsImlhdCI6MTU5ODI3MzQ4NSwiZXhwIjoxNTk4MzU5ODg1fQ.7obwM0R64eQdAwWUTQFyLitEHwwv7XXzzn4SvR0hgUc"}]
08/24/2020 02:50:17 PM Sending packet PING data None
How to fix it?
What problem do you need to fix? The log doesn't show any problem.
Hi.
The problem is that I do not have the response from the server when executing: sio.emit ('report-client-register', data = {'token': vToken, 'channelRole': 'client'}) and therefore the instructions below.
Events do not have responses in Socket.IO. If the server is configured to send ACK packets, then you can add a callback to your emit, which will be called when the server acknowledges the event. The call() function combines the emit and the callback and makes it look like a single thing, so maybe that's what you are looking for.
Work fine. Thanks.
Most helpful comment
Events do not have responses in Socket.IO. If the server is configured to send ACK packets, then you can add a callback to your emit, which will be called when the server acknowledges the event. The
call()function combines the emit and the callback and makes it look like a single thing, so maybe that's what you are looking for.