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.

client timeout error on emit

See original GitHub issue

I am receiving a timeout error when attempting to emit an event to a nodejs socket.io server namespace. There are no issues when the client connects to the server and the namespace, but for some reason the server does not detect emitted events from the python client (there is no issue when this is done from nodejs socket.io-client). The package versions are: python-socketio 4.6.0, python-engineio 3.14.2, socket.io (nodejs) 2.3.0.

import socketio

class Resource(ApiClient):
    def __init__(self):
        self.sio_client = socketio.Client()
        self.sio_client.connect(self.base_url, headers={
            'Authorization': 'Bearer {}'.format(self.api_key)
         }, namespaces=['/resource/']) # no issues connecting to server

    def upload(self, data: list):
        self.sio_client.emit(event='upload', data=data, namespace='/resource/') # gives timeout error after 60 seconds. 

Thanks

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
miguelgrinbergcommented, Jan 20, 2021

The connection is asynchronous. The connect() call initiates it, but the connection isn’t finalized until your connect event handler fires up. This is an area that I hope I’ll be able to improve in a future release, as this generates some confusion, but this is how the connection works at this time.

0reactions
deepthought-devcommented, Jan 20, 2021

I see, though I cannot understand how this can technically happen as in the code the client connects to the server in init before emitting the event in the upload function, unless for some reason there isn’t enough time to connect and it tries to emit before it has finished connecting. Anyways, I found a solution to the problem by adding a time.sleep(1) between the client connecting to the server and emitting the event, the server now receives the event without issues. Thanks again.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why am I getting 'timeout' error on socket.io and self-signed ...
I created a nodejs server with https. There is no problem when making a GET request, but when connecting with another nodejs application...
Read more >
A Complete Guide to Timeouts in Node.js - Better Stack
Timeouts on outgoing HTTP requests (Client timeouts)​​ Therefore, this section will discuss how to set timeouts on outgoing HTTP requests in Node. js....
Read more >
Emitting events | Socket.IO
IO API is inspired from the Node.js EventEmitter, which means you can emit events on one side and register listeners on the other:....
Read more >
JavaScript & Node.js Examples of Socket.setTimeout (net)
stream.setTimeout(timeout, function () { client.destroy(); client.emit('close'); ... onSocketData.bind(this)); this.socket.on('error', this.
Read more >
Net | Node.js v19.3.0 Documentation
setTimeout(timeout[, callback]); socket.timeout; socket.unref(); socket.write(data[ ... Emitted when a new connection is made. socket is an instance of net.
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