client timeout error on emit
See original GitHub issueI 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:
- Created 3 years ago
- Comments:8 (4 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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.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.