0

I am using MQTT protocol to send data . I have set NoRetry() as i wanted to go into callback if any network failures are there. but it is coming only after 4 min . can i change that timeout period to some milli seconds when i am in NoRetry() . Reason is that in case if figured out the error in sending the message i can save data locally and send when connectivity comes back.

Amjath Khan
  • 185
  • 11

1 Answers1

0

You could try doing a client.SetOptions({keepalive: 10}). The number is the number of second between keep alive packets. Do the setOptions before the open/connect occurs. Also set all of your options at the same time.

Note of course that this will generate more network traffic. Normally the keepalive pings are at 180 seconds.

  • i tried by doing client.setOptions({keepalive : 10} ) ; var client = clientFromConnectionString(connectionString); client.setOptions({keepalive: 10}); client.setRetryPolicy(new NoRetry()); client.open(connectCallback); But it did not worked out i am getting failure in sending the message only after 5 minutes Log Here with time – Amjath Khan Nov 02 '18 at 11:51
  • status: MessageEnqueued Fri Nov 02 2018 11:18:18 GMT+0530 (IST) ### Here i disconnected with internet i am disconnected Fri Nov 02 2018 11:24:15 GMT+0530 (IST) this is error sendeventNotConnectedError: getaddrinfo EAI_AGAIN cyientiothub.azure-devices.net:8883 Fri Nov 02 2018 11:24:15 GMT+0530 (IST) you can see that both sendEvent and disconnection from IoT hub reported to me only after 6 min – Amjath Khan Nov 02 '18 at 11:52
  • @TonyErcolanco Firstly Thank you for responding . I am using is-internet-available module to check whether internet connectivity is there or not ? As it is taking 400ms for this every time i am sending message , i wanted to avoid this , is there any way i can know that client is connected or not ? Asynchronously . And for suppose my internet will be unavailable for more than 5-6 hours and it gets connectivity back , then will automatically connectivity happens or i need to do client.close() then cleint.removeAllListner() and cleint.open( connectionstring ) – Amjath Khan Nov 02 '18 at 12:01