paho.mqtt.python icon indicating copy to clipboard operation
paho.mqtt.python copied to clipboard

Customizable Connect Timeout

Open cartertinney opened this issue 4 years ago • 2 comments

It seems as though the socket timeout for establishing a connection is set to 5 seconds with no way of changing it, due to there being no way to set the ._connect_timeout attribute without accessing the convention-private attribute itself.

Is there a particular reason why this is this way? We have a requirement of supporting up to 60 seconds to establish a connection rather than just the 5 currently allowed.

I would be willing to implement an API to allow for this customization if necessary.

cartertinney avatar Nov 16 '21 00:11 cartertinney

It seems as though the socket timeout for establishing a connection is set to 5 seconds with no way of changing it, due to there being no way to set the ._connect_timeout attribute without accessing the convention-private attribute itself.

Is there a particular reason why this is this way? We have a requirement of supporting up to 60 seconds to establish a connection rather than just the 5 currently allowed.

I would be willing to implement an API to allow for this customization if necessary.

it'd be enough to add a parameter in the Client constructor

babaMar avatar Jan 25 '22 10:01 babaMar

@cartertinney you can also overwrite the attribute after instantiating the client, as in python there are real private variables

mqtt_client = mqtt.Client()
mqtt_client._connect_timeout = 1.0

babaMar avatar Jan 25 '22 11:01 babaMar