Why can't I re-subscribe to a topic when I use a sock5 proxy? When the proxy is disconnected, it automatically reconnects successfully.
LeslieLau4me opened this issue · 0 comments
Is your feature request related to a problem? Please describe.
I added sock5 support files to the paho-mqtt-src source directory, and modified some of the source code to support sock5 proxy connections. At the same time, I expanded the proxy options in the paho_c_sub.c file to support sock5 proxy options when calling the command line,some changes in MQTTAsync.c may like:
and in paho_c_sub.c:
Then the following effects are achieved: Subscription to the topic is achieved through the proxy proxy through pub_c_sub:
paho_c_sub -t /example/test1 -c ssl://mysslconnect.com:9883 --insecure --cafile /etc/ssl/gw/cafile/ca.crt --cert /etc/ssl/gw/certfile/client.crt --key /etc/ssl/gw/keyfile/client.key --keypass "mypasskey" --socks5-proxy socks5h://mysocket:7898 -v --trace protocol
Then I started to receive data from this topic, but when I manually disconnected the sock5 proxy (it would automatically reconnect after a short time), I could no longer subscribe to information from this topic after sock5 reconnected.
Reestablished the connection but no more data is received:
Back to the code, I found that after the MQTT connection is successfully established, the callback function pointer of connect.onSuccess will be automatically set to null in the code. In this way, if I subscribe to the topic in onSuccess, then after the connection is restored, the callback set by the user will not be executed and the original topic will not be subscribed again. Regardless of whether cleansession is true or false, this connection seems to lose its meaning. Why should I maintain a connection that cannot receive the topic subscription I originally expected?
when start reconnecting:
Why do this? At the same time, how can we better enable users to resubscribe to the original topic after the connection is restored? Perhaps this is my most original question.
Describe the solution you'd like
Should the callback function pointer of onSuccess set by the user be retained, or should the original MQTT topic of the user be saved by other means to maintain data continuity as much as possible after the connection is passively disconnected and restored?