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

Client.reinitialise() changes transport type

Open stradiot opened this issue 2 years ago • 2 comments

The reinitialise() method of the client does not take the same arguments as the constructor (contrary to what the documentation says). This causes the unspecified arguments to change to default values.

If using websockets as a transport type, after calling reinitialise() the transport is changed to the default TCP and the client is unable to connect. This also applies to other unsupported arguments (protocol version and autoreconnect).

image image image

stradiot avatar Nov 28 '23 07:11 stradiot

Do you see an use case of reinitialise that is not solved by really re-creating the client ? E.g. instead of:

myclient.reinitialise([...])

Do:

myclient = paho.Client([...])

I think the second option is much better as it's clear that nothing is kept and it would solve your issue.

PierreF avatar Jan 07 '24 10:01 PierreF

Looks like the docs may have been updated to remove the text that was in error. Note that #850 requires a change to this function so may be worth considering addressing the protocol issue at the same time (referencing that issue so there is a link)

MattBrittan avatar Jul 17 '24 23:07 MattBrittan