Closed bgb10 closed 8 months ago
Well your code is wrong to start with. The connect method takes a username and password (and probably wait=True). After that you're not actually sending anything, so the connection isn't actually used, and it would eventually time out by my understanding of the protocol. (I don't think your raw python connection example really proves the timeout behaviour either, because you're not actually using the socket after the initial connection).
Even if you did connect correctly, and were sending messages through the connection, I think you still need heartbeating enabled to keep the read connection open (i.e. if you connect without heartbeating and send messages, it will still time out after 5 seconds).
In summary, I don't think this is a bug.
Summary
An unexpected disconnection issue with
stomp.Connection(timeout=5)
, where connections terminate after 5 seconds despite a successful initial connection, contrasting with Python socket behavior which maintains the connection post-timeout.Problem
I'm running
activeMQ
in localhost, and I confirmed connection are successfully established.If I give
stomp.Connection()
a timeout option as an argument, to my knowledge, timeout option would only affects only when initial connection. For example, if I usestomp.Connection(timeout=5)
, the expected behavior is that an exception will be thrown if connection establishment fails for 5 seconds on the first connection.However, what I've observed is that the connection is being terminated after 5 seconds even if the connection successfully established and even when activeMQ is still available.
Code Example
If I run the code below, my expectation is that the timeout option is only applied to the initial connection, so if the connection is made within 5 seconds, the connection should be maintained. However, as you can see in terminal, the connection is disconnected after about 5 seconds. (I think the initial ‘False’ is due to the connection not being fully established yet)
If I write client code that does something similar with the python standard library's socket (server is on), the connection will still be maintained after the timeout has passed.
Suspected problem
There are a couple of possible problems.
Thank you for maintaining a good library. Hope for comments.