Topic: PIC32 MQTT state machine stuck upon router power cycle

Hi,

I have a question regarding MQTT with PIC32 Harmony v1.08.

My APP state machine connects very well to MQTT broker.

The problem arises when we run a test that network shuts down (router is powered off and then back on again).

Most of the time the APP state machine recovers, but sometimes not.

The sequence being executed is:

1. TCPIP stack Initialization
2. polls on the state that has rc = MqttClientNet_Init(); until rc == MQTT_CODE_SUCCESS and then moves on to the next state.
3. polls on the state that has MqttClient_Init(); until rc == MQTT_CODE_SUCCESS and then moves on to the next state.
4. polls on the state that has MqttClient_NetConnect().

When the system fails, MqttClient_NetConnect() returns rc == MQTT_CODE_CONTINUE forever and never gets MQTT_CODE_SUCCESS.

Is there any race here between physical network connection and attempt to connect to broker?

I need some help. If pieces of code are required i can upload them.

Regards,

Gil

Share

Re: PIC32 MQTT state machine stuck upon router power cycle

Hi Gil,

Thanks for contacting wolfSSL support. I see that there was a bugfix that may pertain to the issue you are having:
https://github.com/wolfSSL/wolfMQTT/issues/88

Could you check and see if this fixes the issue of MqttClient_NetConnect() returning rc == MQTT_CODE_CONTINUE forever ?

Thanks,
Eric Blankenhorn
wolfSSL Support

Re: PIC32 MQTT state machine stuck upon router power cycle

Hi Eric,

We already have the fix present.

But i did some more digging and found that on a successful connection function             

rc = SOCK_CONNECT(sock->fd, (struct sockaddr*)&sock->addr, sizeof(sock->addr));

returns -1 for some time until connection is made and then becomes 0.
While in the failing state, SOCK_CONNECT returns -1 forever.

Regards,
Gil

Share

Re: PIC32 MQTT state machine stuck upon router power cycle

By the way, maybe this info will help:

I discovered that the failing scenario usually happens after letting the MQTT client idle for about twenty minutes.

Idle means connection is ok, no data transfer only KEEP ALIVES are present between server and client. Then (after about 20 minutes) router is powered off and then on.

Thanks,
Gil

Share

Re: PIC32 MQTT state machine stuck upon router power cycle

SOCK_CONNECT() keep returning error 119 - EINPROGRESS upon failure

Thanks

Share

Re: PIC32 MQTT state machine stuck upon router power cycle

Hi Gil,

Thank you for providing more information. The "connect" API is outside of the wolfMQTT library. Can you reproduce this problem with any of the other Harmony network examples?

Thanks,
Eric Blankenhorn
wolfSSL Support

Re: PIC32 MQTT state machine stuck upon router power cycle

Hi Eric,

Reproduce this problem with any of the other Harmony network examples might require a lot of (currently unavailable) effort and change too many parameters in the code that might eliminate the error effect.

I think i might try consulting with Microchip guys for now.

If that doesn't work i'll get back here.

Thanks.

Share