cancel
Showing results for 
Search instead for 
Did you mean: 

WICED Studio Wi-Fi Combo

Anonymous
Not applicable

Hi mwf_mmfae,

I am not able to do a Reconnect to MQTT If the connection goes down. I can see a hang in the system if I try to do a MQTT Reconnect. While debugging I found that its coming from a call to ssl_handshake_server_async()

I tried with 3.5.2 SDK and also with 4.0 (Back porting the core changes from 4.0 to 3.5.2 wrt BESL)

The code snippet is

   while(1)

{

  do

  {

  ret = aws_mqtt_conn_open( app_info.mqtt_object, mqtt_connection_event_cb );

  connection_retries++ ;

  } while ( ( ret != WICED_SUCCESS ) && ( connection_retries < WICED_MQTT_CONNECTION_NUMBER_OF_RETRIES ) );

do

{

ret = aws_mqtt_app_subscribe( app_info.mqtt_object, app_info.shadow_delta_topic , WICED_MQTT_QOS_DELIVER_AT_MOST_ONCE );

connection_retries++ ;

} while ( ( ret != WICED_SUCCESS ) && ( connection_retries < WICED_MQTT_CONNECTION_NUMBER_OF_RETRIES ) );

      shadow_close();

  wiced_rtos_delay_milliseconds(1000);

}

In my shadow close I am just calling

    mqtt_network_deinit(&(((mqtt_connection_t*)app_info.mqtt_object)->socket));

    mqtt_connection_deinit((mqtt_connection_t*) app_info.mqtt_object);

Am I doing any mistake. Please go through this and give some suggestions

If posible can you provide me a sample application or an API which does the Reconnection for MQTT, which is like mandatory.

46 Replies
AxLi_1746341
Honored Contributor

Just want to clarify if this is MQTT issue or BESL issue:

Does it work if you use MQTT without TLS?

0 Likes
Anonymous
Not applicable

Hi Axel,

I am not sure about MQTT without TLS

One more update is there. I tried two combinations

One I used the 3.5.2 provided BESL Static Library and took the other changes wrt BESL from 4.0. That time I am getting a TLS Error 5017 and the network connection is failing, even though I was able to connect atleast once with the MQTT with same certificates

When I replaced the BESL static library with the one I got from 4.0 I am getting stuck after calling the ssl_handshake_server_async() for 10 times. Its really weird and I am not able to understand the issue only.

Thanks in advance

0 Likes
JeGu_2199941
Contributor II

Make sure you set "peer_cn" properly 3.5.2 and 4.0.

See WICED SDK 3.5.2 SSL/TLS Verify Peer CN Bug  and more other threads for more information.

0 Likes
MichaelF_56
Moderator
Moderator

Engineering informed me that we have a fix in place for this issue within the next release of the SDK.  Unfortunately, I do not have a release date to share.

0 Likes
AxLi_1746341
Honored Contributor

mwf_mmfae wrote:

Engineering informed me that we have a fix in place for this issue within the next release of the SDK.  Unfortunately, I do not have a release date to share.

mwf_mmfae​,

I really don't understand your policy to maintain your binary code.

Why not deliver the exactly fix to users if you already have a fix in place so anandram​ can continue use the SDK he is currently using.

In additional, if it's really a fix in binary code you just prove all previous SDKs indeed has problem so cannot be used for production at all.

0 Likes
Anonymous
Not applicable

Hi Axel,

I dont see any issues with Certificates as with bare 3.5.2 without any porting changes I am able to connect and do all the AWS stuffs until i try a reconnect. But when I am trying the same with back ported 3.5.2 SDK from 4.0 I am getting the 5017 error.

I am using my peer_cn with wildcard entry only

conninfo.peer_cn = (uint8_t*) "*.iot.us-west-2.amazonaws.com" which I think is correct.

Hi mwf_mmfae,

Can you at-least say what is the issue or at-least give the new library alone. We are in a crucial situation and we can't keep waiting for your new releases. We need to release to the customers with AWS working seamlessly within this week. Please, please provide me with the library atleast or give some insight on the issue. 

0 Likes
MichaelF_56
Moderator
Moderator

At this point, I do not have a response. Sorry. I will continue to escalate internally, but I am limited in that regard.

gangirash

0 Likes
AxLi_1746341
Honored Contributor

anandram wrote:

Hi Axel,

I dont see any issues with Certificates as with bare 3.5.2 without any porting changes I am able to connect and do all the AWS stuffs until i try a reconnect. But when I am trying the same with back ported 3.5.2 SDK from 4.0 I am getting the 5017 error.

I am using my peer_cn with wildcard entry only

conninfo.peer_cn = (uint8_t*) "*.iot.us-west-2.amazonaws.com" which I think is correct.

5017 error means TLS_ERROR_UNEXPECTED_MESSAGE and it's likely returned from ssl_handshake_client_async().

The problem is in the closed-source library or the way you use the library.

Anonymous
Not applicable

Hi Axel,

Can you just elaborate on what you meant by "the way you use the library"

0 Likes
AxLi_1746341
Honored Contributor

anandram wrote:

Hi Axel,

Can you just elaborate on what you meant by "the way you use the library"

From my point of view, making a connection and re-connect is the same thing in TLS handshake.

So I have no idea why you can connect but have problem to re-connect especially the error code is TLS related error.

Maybe the BESL indeed has problem in this SDK version; maybe the way to do reconnect is incorrect.

I don't see any thing wrong from the code you post. But I also don't know the correct way to do mqtt re-connect using the mqtt library.

I think most people reference the mqtt snip code but maybe the snip code never test the reconnect case at all.

Anonymous
Not applicable

Hi Axel,

When I checked the mqtt snip code its without any security and donot use TLS at all. So I believe it works without any issue.

Is that right.

0 Likes
AxLi_1746341
Honored Contributor

anandram wrote:

Hi Axel,    When I checked the mqtt snip code its without any security and donot use TLS at all. So I believe it works without any issue.  Is that right.

I think you need support from cypress team as I think the issue is mainly in sdk rather than your application.

MichaelF_56
Moderator
Moderator

I will confirm this week that the following issues have all been identified and will appear resolved in the next release of the SDK.

MQTT stability issue

https://community.cypress.com/message/29590

having trouble in using MQTT in my application

https://community.cypress.com/message/29588

MQTT Reconnection causing hang in the system

https://community.cypress.com/message/29560

SDK-3.7.0: Detect memory leak while testing https_client snip code

https://community.cypress.com/message/29552

Reconnect After MQTT Disconnect SDK 3.7.0-3

https://community.cypress.com/message/29404

(WICED 3.7.0) MQTT Disconnect & Reconnect with TLS Problem

https://community.cypress.com/thread/7435

User or Apps Team Resolved and provided workaround::

iOT AWS MQTT Subscribe issues on BCM94343AVN

https://community.cypress.com/message/28960

MQTT deinit

https://community.cypress.com/message/28965

0 Likes
Anonymous
Not applicable

Any Updates

0 Likes
Anonymous
Not applicable

Hello anandram,

We working on MQTT and use wiced SDK 3.5.2

I facing same problem when i check connection with broker second time it hang system.

i think, you try with reopen (connect) before close connection with broker and then try reopen the mqtt connection.

In our project it worked fine.

thanks and regards

Chintan patel

0 Likes
Anonymous
Not applicable

Hi Chintan,

what if wifi connection goes down and then comes back later. will this still work

If yes can u elaborate a little bit more pointing to the functions that you are talking while closing and while opening

Thanks in advance

0 Likes
AxLi_1746341
Honored Contributor

mwf_mmfae wrote:

I will confirm this week that the following issues have all been identified and will appear resolved in the next release of the SDK.

I might misunderstand what you mean about "next release".

I'm waiting for 3.x release rather than 4.0.1.

Anonymous
Not applicable

Hi Axel,

Same here. Now I have to start porting from 3.5.2 to 4.0.1, which is again a hectic Job.

0 Likes
AxLi_1746341
Honored Contributor

anandram wrote:

Hi Axel,

Same here. Now I have to start porting from 3.5.2 to 4.0.1, which is again a hectic Job.

You had better do some test before moving to 4.0.1.

I'm not sure if it is really fixed in 4.0.1.

The changes in MQTT is small and you have experience copy BESL from 4.0.0 to your current SDK.

Maybe you can backport the MQTT and BESL to your current SDK  for testing first. This might be easier.

0 Likes
AxLi_1746341
Honored Contributor

axel.lin wrote:

I might misunderstand what you mean about "next release".

I'm waiting for 3.x release rather than 4.0.1.

mwf_mmfae

Can you tell me when will next 3.x release available?

I'm running out of time. (I have been waiting for 5 months for BESL memory leak fix).

Anonymous
Not applicable

Hi mwf_mmfae,

Still reconnection is not smooth. The same experiment which I was doing in 3.5.2 I tried with 4.0.1 of continuous Connection & ReConnection in a while(1).Even though there is no hang as before, what I have observed is that IP Address for the server is changing over a period of time and once it changes its IP I am not able to connect with the same certificates though with the same certificates I was able to connect just before the change in IP.

If I keep on going then I am getting the error 5003 which corresponds to OUT_OF_MEMORY. What fix you have done NO IDEA. But its pretty bad the way you give releases

0 Likes
ShBB_2186006
New Contributor II

mwf_mmfaeIoT DesignsUSIWICED Wi-Fi

Dear Community Manager,

   We are due to start production in end of Dec-16 and this is a major blocker. With this experience, it will trigger us to re-think in using the solution for any further IoT Based product development where AWS or any other cloud connectivity is needed.

   Request greater attention and help in resolving this issue.

Thanks and regards,
Gupta

0 Likes
KausikB_86
Employee

Hi Anandram,

I am part of the core team.

I suppose you are referring to the MQTT reconnect not being smooth. In WICED 4.0.1 release, we did make changes to cleanup the MQTT data structures upon disconnection. I understand that you are still seeing some issues with reconnection. Can you please provide details on the app that you are using? or if possible, please attach the app to this post and we can have this checked up.

Appreciate your patience.

Regards

/Kausik

AxLi_1746341
Honored Contributor

kausik wrote:

Hi Anandram,

I am part of the core team.

I suppose you are referring to the MQTT reconnect not being smooth. In WICED 4.0.1 release, we did make changes to

The problem is not for a specific issue.

The whole process has problem as I mentioned earlier in below thread.

SDK-3.7.0: Detect memory leak while testing https_client snip code

0 Likes
KausikB_86
Employee

Hi,

The fix for this thread 'SDK-3.7.0: Detect memory leak while testing https_client snip code ' will be part of the 3.7.0-7 maintenance release. This will be made available in a day or two. Mike just confirmed the same on the other thread as well. We have verified with GCM/CCM and DHE-RSA cipher suites that there are no memory leaks. The BESL memory leak fixes have also gone into the 4.0.1 SDK release.

As for the MQTT reconnect issue, the fix is only part of 4.0.1 release. However, as you said, since there are several posts on this topic, we do intend to provide a patch for this issue. And this patch can be applied independently. If AnandRam provides more details on the issue that he is observing, we would be able to provide a robust fix. On a side note, the SDK also includes a secure MQTT snippet app 'secure_mqtt'. I rea

Hope this clarifies.

regards

/Kausik

AxLi_1746341
Honored Contributor

kausik

You totally don't get my point, but that thread is pretty long.

I re-post as below:

I think something very wrong in WICED SDK release process!

If cypress team can release fixes only for the SDK bugs (including source code fix or library fix) on the forum by patch or by zip files,

People don't need to wait for new sdk release. People can continue use the SDK they are working on.

Otherwise cypress team needs to frequently update sdk release.

However, current situation is: No bug fix in any form for very long time.

I use the SDK so I do care about the quality of the SDK.

I have tried asking to improve the process, but I don't see too much improvement.

e.g.

Let the core team review user provided patches on the forum.

For the person familiar with the code, it's easy to tell if a fix is correct or not.

Follow up the pending issues. As I have pointed out many issues are still pending without follow up actions.

No response from cypress, it's so silence.

And most importantly, cypress needs to provide bug fix for the binary library in older SDK.

Evey new sdk can become old sdk some doay. You can not keep asking users to upgrade SDK.

For example, all older 3.x SDK has problem connecting IIS server using TLS-v1.2 due to a bug in BESL library.

This means all wiced devices on the market using https has this problem.

I just cannot believe there is no fix from cypress for such issue.

So

1) I wait for BESL memory leak fix for 5 months, and still don''t get it so far.

   Do you think this is normal situation? It's really very had to get bug fix for the closed-source library.

2) I have customers report not able to connect azure-iot.

   It's because of the BESL bug in SDK-3.1.2.

   Would you release BESL bug fix for SDK-3.1.2?

AxLi_1746341
Honored Contributor

2) I have customers report not able to connect azure-iot.

   It's because of the BESL bug in SDK-3.1.2.

   Would you release BESL bug fix for SDK-3.1.2?

For above issue, I had send an case on SFDC (Tech Support MyCase 00304376) on 11/22/2016.

I don't get response so far.

KausikB_86
Employee

Hello Axel,

Thanks for posting the details again. Two parts here:

  1. Issues with BESL and MQTT reconnect
  2. Improvements to the release process to allow point fixes to be provided instead of having to upgrade the SDK.

So far, my replies/posts only address (1). Your suggestions on (2) are very useful and valid. I will discuss internally about how we can address your concerns. Hopefully, with releases: 3.7.0-7 and 4.0.1, (1) gets addressed, while we work on addressing (2). Thanks for your understanding.

Regards

/Kausik

AxLi_1746341
Honored Contributor

kask wrote:

Hello Axel,

Thanks for posting the details again. Two parts here:

  1. Issues with BESL and MQTT reconnect
  2. Improvements to the release process to allow point fixes to be provided instead of having to upgrade the SDK.

So far, my replies/posts only address (1). Your suggestions on (2) are very useful and valid. I will discuss internally about how we can address your concerns. Hopefully, with releases: 3.7.0-7 and 4.0.1, (1) gets addressed, while we work on addressing (2). Thanks for your understanding.

Regards

/Kausik

kask

I don't get BESL fix for sdk-3.1.2 as I reported very log time ago (It has problem to connect IIS/Azure-iot servers using TLSv1.2).

No follow up at all.

0 Likes
AxLi_1746341
Honored Contributor

kask wrote:

Hello Axel,

Thanks for posting the details again. Two parts here:

  1. Issues with BESL and MQTT reconnect
  2. Improvements to the release process to allow point fixes to be provided instead of having to upgrade the SDK.

So far, my replies/posts only address (1). Your suggestions on (2) are very useful and valid. I will discuss internally about how we can address your concerns. Hopefully, with releases: 3.7.0-7 and 4.0.1, (1) gets addressed, while we work on addressing (2). Thanks for your understanding.

Regards

/Kausik

I don't see too much improvement regarding (2) as cypress still let people waiting for quite long time for getting fixes via new releases.

0 Likes
AxLi_1746341
Honored Contributor

axel.lin wrote:

For example, all older 3.x SDK has problem connecting IIS server using TLS-v1.2 due to a bug in BESL library.

This means all wiced devices on the market using https has this problem.

2) I have customers report not able to connect azure-iot.

   It's because of the BESL bug in SDK-3.1.2.

   Would you release BESL bug fix for SDK-3.1.2?

kausik

Do you have schedule for the BESL TLS-v1.2 bug fix?

0 Likes
Anonymous
Not applicable

Hi Kausik,

Its good to see that finally someone from dev team is appearing on the forum

As I dont understand how to attach any files I will put the code snippet where I am getting the issue. May be you can take a look and correct me if I am doing something wrong. Basically I have taken the demo/aws_iot/shadow code. There I have done a small change in shadow.c.

Rest all are same. Please use a valid certificates. Thats all

void application_start( void )

{

    wiced_result_t   ret = WICED_SUCCESS;

    int              connection_retries = 0;

   

    ret = aws_app_init(&app_info);

    wiced_JSON_parser_register_callback(parse_json_shadow_status);

    wiced_gpio_input_irq_enable( WICED_BUTTON1, IRQ_TRIGGER_RISING_EDGE, setpoint_control_keypad_handler, NULL );

    while(1)

    {

  do

  {

  ret = aws_mqtt_conn_open( app_info.mqtt_object, mqtt_connection_event_cb );

  connection_retries++ ;

  } while ( ( ret != WICED_SUCCESS ) && ( connection_retries < WICED_MQTT_CONNECTION_NUMBER_OF_RETRIES ) );

  aws_mqtt_app_publish( app_info.mqtt_object, WICED_MQTT_QOS_DELIVER_AT_LEAST_ONCE, (uint8_t*)app_info.shadow_state_topic, (uint8_t*)SHADOW_PUBLISH_MESSAGE_STR_OFF ,sizeof(SHADOW_PUBLISH_MESSAGE_STR_OFF) );

  wiced_rtos_delay_milliseconds( MQTT_DELAY_IN_MILLISECONDS * 2 );

  aws_mqtt_app_subscribe( app_info.mqtt_object, app_info.shadow_delta_topic , WICED_MQTT_QOS_DELIVER_AT_LEAST_ONCE );

     aws_mqtt_conn_close(app_info.mqtt_object);

     mqtt_connection_deinit((mqtt_connection_t*) app_info.mqtt_object);

    }

    while ( 1 )

    {

        /* Wait forever on wake semaphore until the wake button is pressed */

        wiced_rtos_get_semaphore( &app_info.wake_semaphore, WICED_NEVER_TIMEOUT );

        /* Toggle the LED */

        if ( strcasecmp( led_status, "ON" ) == 0 )

        {

            wiced_gpio_output_low( WICED_LED1 );

            led_status = "OFF";

            strcpy(req_led_status, led_status);

            aws_mqtt_app_publish( app_info.mqtt_object, WICED_MQTT_QOS_DELIVER_AT_LEAST_ONCE, (uint8_t*)app_info.shadow_state_topic, (uint8_t*)SHADOW_PUBLISH_MESSAGE_STR_OFF_DESIRED_AND_REPORTED ,sizeof(SHADOW_PUBLISH_MESSAGE_STR_OFF_DESIRED_AND_REPORTED) );

        }

        else

        {

            wiced_gpio_output_high( WICED_LED1 );

            led_status = "ON";

            strcpy(req_led_status, led_status);

            aws_mqtt_app_publish( app_info.mqtt_object, WICED_MQTT_QOS_DELIVER_AT_LEAST_ONCE, (uint8_t*)app_info.shadow_state_topic, (uint8_t*)SHADOW_PUBLISH_MESSAGE_STR_ON_DESIRED_AND_REPORTED ,sizeof(SHADOW_PUBLISH_MESSAGE_STR_ON_DESIRED_AND_REPORTED) );

        }

    }

    aws_mqtt_app_unsubscribe( app_info.mqtt_object, app_info.shadow_delta_topic );

    aws_mqtt_conn_close( app_info.mqtt_object );

    wiced_rtos_deinit_semaphore( &app_info.msg_semaphore );

    ret = wiced_mqtt_deinit( app_info.mqtt_object );

    free( app_info.mqtt_object );

    app_info.mqtt_object = NULL;

    return;

}

If you run this for some 10-15 times I will get the error 5003 from tls library

I will put the log also with this.

[MQTT] Successfully connected MQTT Broker

Publish SUCCEEDED for topic [$aws/things/lightbulb/shadow/update]

Subscribe SUCCEEDED for topic [$aws/things/lightbulb/shadow/update/delta]

[MQTT LIB] connection deinit

[MQTT LIB] connection deinit

[MQTT] Connecting to broker 54.148.236.94 ...

[MQTT] Connecting to MQTT Broker anantha...

Init Network

Completed network

[MQTT] Successfully connected MQTT Broker

Publish SUCCEEDED for topic [$aws/things/lightbulb/shadow/update]

Subscribe SUCCEEDED for topic [$aws/things/lightbulb/shadow/update/delta]

[MQTT LIB] connection deinit

[MQTT LIB] connection deinit

[MQTT] Connecting to broker 54.148.236.94 ...

[MQTT] Connecting to MQTT Broker anantha...

Init Network

Completed network

[MQTT] Successfully connected MQTT Broker

Publish SUCCEEDED for topic [$aws/things/lightbulb/shadow/update]

Subscribe SUCCEEDED for topic [$aws/things/lightbulb/shadow/update/delta]

[MQTT LIB] connection deinit

[MQTT LIB] connection deinit

[MQTT] Connecting to broker 54.148.236.94 ...

[MQTT] Connecting to MQTT Broker anantha...

Init Network

Completed network

[MQTT] Successfully connected MQTT Broker

Publish SUCCEEDED for topic [$aws/things/lightbulb/shadow/update]

Subscribe SUCCEEDED for topic [$aws/things/lightbulb/shadow/update/delta]

[MQTT LIB] connection deinit

[MQTT LIB] connection deinit

[MQTT] Connecting to broker 54.148.236.94 ...

[MQTT] Connecting to MQTT Broker anantha...

Init Network

Completed network

[MQTT] Successfully connected MQTT Broker

Publish SUCCEEDED for topic [$aws/things/lightbulb/shadow/update]

Subscribe SUCCEEDED for topic [$aws/things/lightbulb/shadow/update/delta]

[MQTT LIB] connection deinit

[MQTT LIB] connection deinit

[MQTT] Connecting to broker 54.148.236.94 ...

[MQTT] Connecting to MQTT Broker anantha...

Init Network

Completed network

[MQTT] Successfully connected MQTT Broker

Publish SUCCEEDED for topic [$aws/things/lightbulb/shadow/update]

Subscribe SUCCEEDED for topic [$aws/things/lightbulb/shadow/update/delta]

[MQTT LIB] connection deinit

[MQTT LIB] connection deinit

[MQTT] Connecting to broker 54.148.236.94 ...

[MQTT] Connecting to MQTT Broker anantha...

Init Network

Completed network

[MQTT] Successfully connected MQTT Broker

Publish SUCCEEDED for topic [$aws/things/lightbulb/shadow/update]

Subscribe SUCCEEDED for topic [$aws/things/lightbulb/shadow/update/delta]

[MQTT LIB] connection deinit

[MQTT LIB] connection deinit

[MQTT] Connecting to broker 54.148.236.94 ...

[MQTT] Connecting to MQTT Broker anantha...

Init Network

Completed network

[MQTT] Successfully connected MQTT Broker

Publish SUCCEEDED for topic [$aws/things/lightbulb/shadow/update]

Subscribe SUCCEEDED for topic [$aws/things/lightbulb/shadow/update/delta]

[MQTT LIB] connection deinit

[MQTT LIB] connection deinit

[MQTT] Connecting to broker 35.160.47.159 ...

[MQTT] Connecting to MQTT Broker anantha...

Init Network

Error with TLS client handshake 5035

Completed network

Ret Value of ret is 5035

[MQTT] Failed to connect MQTT Broker

[MQTT LIB] connection deinit

[MQTT] Connecting to broker 35.160.47.159 ...

[MQTT] Connecting to MQTT Broker anantha...

Init Network

Error with TLS client handshake 5003

Completed network

Ret Value of ret is 5003

[MQTT] Failed to connect MQTT Broker

[MQTT LIB] connection deinit

[MQTT] Connecting to broker 35.160.47.159 ...

[MQTT] Connecting to MQTT Broker anantha...

Init Network

Error with TLS client handshake 5003

Completed network

Ret Value of ret is 5003

[MQTT] Failed to connect MQTT Broker

[MQTT LIB] connection deinit

[MQTT] Connecting to broker 35.160.47.159 ...

[MQTT] Connecting to MQTT Broker anantha...

Init Network

Error with TLS client handshake 5003

Completed network

Ret Value of ret is 5003

[MQTT] Failed to connect MQTT Broker

[MQTT LIB] connection deinit

[MQTT] Connecting to broker 35.160.47.159 ...

[MQTT] Connecting to MQTT Broker anantha...

Init Network

Error with TLS client handshake 5003

Completed network

Ret Value of ret is 5003

[MQTT] Failed to connect MQTT Broker

0 Likes
KausikB_86
Employee

Hello AnandRam,

Thanks for sharing the code. I reviewed the shadow.c file - the only change I would suggest is pasted below in 'Bold'. Please take a look. I will also try these changes in parallel. Of course you need to use the 4.0.1 SDK as the MQTT library reconnect cleanup logic is present starting 4.0.1 SDK.

<....snip....>

while(1)

{

  do

  {

      ret = aws_mqtt_conn_open( app_info.mqtt_object, mqtt_connection_event_cb );

      connection_retries++ ;

  } while ( ( ret != WICED_SUCCESS ) && ( connection_retries < WICED_MQTT_CONNECTION_NUMBER_OF_RETRIES ) );

  aws_mqtt_app_publish( app_info.mqtt_object, WICED_MQTT_QOS_DELIVER_AT_LEAST_ONCE, (uint8_t*)app_info.shadow_state_topic, (uint8_t*)SHADOW_PUBLISH_MESSAGE_STR_OFF ,sizeof(SHADOW_PUBLISH_MESSAGE_STR_OFF) );

  wiced_rtos_delay_milliseconds( MQTT_DELAY_IN_MILLISECONDS * 2 );

  aws_mqtt_app_subscribe( app_info.mqtt_object, app_info.shadow_delta_topic , WICED_MQTT_QOS_DELIVER_AT_LEAST_ONCE );

  aws_mqtt_conn_close(app_info.mqtt_object);

// Please do not invoke mqtt_connection_deinit API. This is an internal function and any necessary cleanup during

  // disconnect is handled as part of the connection close. Also if you would need to call deinit, then it should be called outside  

// the while loop.  To deinit, please use the wiced_mqtt_deinit API.

  //mqtt_connection_deinit((mqtt_connection_t*) app_info.mqtt_object);

}

<...snip...>

Regards

/Kausik

Anonymous
Not applicable

Hi Kaushik,

If on a disconnection if I only want to do an mqtt_connection_deinit() then which API I need to use. I dont want to do the entire deinit when a disconnection happens and start all together when wifi comes up again. The same scenario I wanted to show you guys. Thats why I was calling aws_connection_open followed by connection_deinit() and continue the same in a while(1).

Or if possible send me a code snippet where you can clearly mention how to do a reconnect to AWS when it goes down

0 Likes
KausikB_86
Employee

Hello Anand,

The aws_mqtt_conn_close API initiates a MQTT disconnect seqeunce (and associated cleanup). This API is adequate, and mqtt_connection_deinit API is not needed to be called. Please note that aws_mqtt_conn_close should be invoked only if the user is initiating the disconnection; if there is a peer or network triggered disconnection, then the necessary cleanup is done internally by the library and the WICED_MQTT_EVENT_TYPE_DISCONNECTED event will be sent by the library to the application. Upon receiving this event, the app should initiate the aws_mqtt_conn_open again. This internal cleanup due to network/peer initiated disconnection was added specifically as part of 4.0.1

Hope this clarifies. Please try this out and if you still have questions, we can provide a sample app.

regards

/Kausik

Anonymous
Not applicable

Hi,

I tried the way you asked me to do. But still I am getting the same error.

Please provide me with a sample app where you can show that multiple user initiated connect & reconnect is working seemlessly

0 Likes
Anonymous
Not applicable

Which version is meant by "next release of the SDK"?

0 Likes
GregG_16
Employee

For attachments, when in dialogue box, click on "Use advanced editor" in upper right, this will allow you to add attachments.

0 Likes
manit_56
Employee

Hi anandram

Please find the attached files which demonstrates sample re-connection logic( not a production quality) please use this file on top of 4.0.1 sdk

secure_mqtt.c -- Demonstrates with test.mosquitto.org

shadow.c -- Demonstrates with shadow application

Hope this will help you.

Thanks & regards

Teja.