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.

Without any answer on socketio.emit

See original GitHub issue

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

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
miguelgrinbergcommented, Aug 24, 2020

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.

0reactions
alcupecommented, Aug 24, 2020

Work fine. Thanks.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Emitting events | Socket.IO
The Socket.IO API is inspired from the Node.js EventEmitter, which means you can emit events on one side and register listeners on the...
Read more >
How to send response back to client using socket.io?
emit call from client to server in response i want to have filename to the client that is not happening with below code...
Read more >
Getting Started — Flask-SocketIO documentation
SocketIO event handlers defined as shown in the previous section can send reply messages to the connected client using the send() and emit()...
Read more >
Socket.IO, React and Node.js: Going Real-Time
It takes socket as an argument, which is nothing more than the communication channel between the client and the server: const getApiAndEmit = ......
Read more >
Everything you need to know about Socket.IO - Ably Realtime
With sockets, when the server receives a new message it will send it to the client and notify them, bypassing the need to...
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