-
Notifications
You must be signed in to change notification settings - Fork 187
Fixed the MQTT client use_tls flag not being reset for a plain reconnect #400
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
Changes from all commits
119b3af
8385932
6ed1451
507583c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2539,7 +2539,11 @@ UCHAR len[2]; | |
| /* CALLED BY */ | ||
| /* */ | ||
| /* _nxd_mqtt_client_connect */ | ||
| /* _nxd_mqtt_client_websocket_connection_status_callback */ | ||
| /* _nxd_mqtt_process_connack */ | ||
| /* _nxd_mqtt_process_disconnect */ | ||
| /* _nxd_mqtt_tcp_establish_process */ | ||
| /* _nxd_mqtt_tls_establish_process */ | ||
| /* */ | ||
| /**************************************************************************/ | ||
| VOID _nxd_mqtt_client_connection_end(NXD_MQTT_CLIENT *client_ptr, ULONG wait_option) | ||
|
|
@@ -2571,6 +2575,10 @@ VOID _nxd_mqtt_client_connection_end(NXD_MQTT_CLIENT *client_ptr, ULONG wait_opt | |
| nx_tcp_socket_disconnect(&(client_ptr -> nxd_mqtt_client_socket), wait_option); | ||
| nx_tcp_client_socket_unbind(&(client_ptr -> nxd_mqtt_client_socket)); | ||
|
|
||
| #ifdef NX_SECURE_ENABLE | ||
| client_ptr -> nxd_mqtt_client_use_tls = 0; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in 8385932, kept minimal as you suggested.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done in 6ed1451 |
||
| #endif | ||
|
|
||
| /* Disable timer if timer has been started. */ | ||
| if (client_ptr -> nxd_mqtt_keepalive) | ||
| { | ||
|
|
@@ -3752,6 +3760,10 @@ UINT old_priority; | |
| } | ||
| #endif /* NX_SECURE_ENABLE */ | ||
| nx_tcp_client_socket_unbind(&(client_ptr -> nxd_mqtt_client_socket)); | ||
|
|
||
| #ifdef NX_SECURE_ENABLE | ||
| client_ptr -> nxd_mqtt_client_use_tls = 0; | ||
| #endif /* NX_SECURE_ENABLE */ | ||
| tx_timer_delete(&(client_ptr -> nxd_mqtt_timer)); | ||
| return(NXD_MQTT_CONNECT_FAILURE); | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added in 507583c as test/regression/mqtt_test/netx_mqtt_tls_to_plain_reconnect_test.c, a separate file so netx_mqtt_connect_test.c keeps covering the plain → secure direction.
It checks that nxd_mqtt_client_use_tls is cleared on both teardown routes, by doing a plain connect on the same client instance after each: after a secure connect that failed at the TCP level, and after a secure connect ended with nxd_mqtt_client_disconnect().
Verified both ways: without the fix the test fails, with the fix it passes. Running it on top of the original commit of this PR fails on the first case only, so your finding 1 reproduces exactly as described.