Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: set TCP transport every time when setting the config (IDFGH-13175) #281

Merged
merged 1 commit into from
Jul 10, 2024

Conversation

huming2207
Copy link
Contributor

Hi @gabsuren @euripedesrocha

We just realised that the TCP transport is not set every time. When the incoming config::network::transport handle is null, it will not be set, and the MQTT client will keep using the previous old (invalid) TCP transport handle.

This is a bit problematic for us. One of our products have a few network interfaces. For example, when using WiFi, the MQTT (over WebSocket) client requires our own TCP transport handle with HTTP proxy, but 4G modem doesn't. When a switchover is needed, we would call esp_mqtt_client_disconnect to disconnect, and then call esp_mqtt_set_config() to reconfigure the client to let it start using or stop using a the TCP transport with proxy.

But now in current implementation, since you have a if (config->network.transport) null check, this will prevent us from clearing the TCP transport setting. Therefore I think we need to remove this unnecessary null check.

Regards,
Jackson

@github-actions github-actions bot changed the title fix: set TCP transport every time when setting the config fix: set TCP transport every time when setting the config (IDFGH-13175) Jul 1, 2024
@euripedesrocha
Copy link
Collaborator

Hi @huming2207, thanks for the update.
From my reading of the code, we are checking if there is valid transport to set. What you want is a way to set it to NULL and use the transport initialized by the mqtt client. Am I correct?
Could you also please add a small note to the field documentation in the header?

@huming2207
Copy link
Contributor Author

Hi @euripedesrocha

From my reading of the code, we are checking if there is valid transport to set. What you want is a way to set it to NULL and use the transport initialized by the mqtt client. Am I correct?

Yes, we are unable to "clear" the previously defined TCP transport handle and let the MQTT client to create its own default TCP handle.

Could you also please add a small note to the field documentation in the header?

Done, see latest commit.

Regards,
Jackson

@AxelLin
Copy link
Contributor

AxelLin commented Jul 31, 2024

Just remind that this fix is not yet available in esp-idf.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants