Server connection to iot device

0 votes
I am working on IoT project, and I should keep the embedded device to be connected with a web-service. So, which is better, requesting the webservice every 1 or 2 seconds, or opening a socket with the server to guarantee the real time operations.

Taking into Consideration that working with sockets, may require me to write a lot of bunches of codes, as there's no frameworks for socket over ARM for example.

Thanks
Oct 3, 2018 in IoT (Internet of Things) by Matt
• 2,270 points
1,546 views

1 answer to this question.

0 votes

It depends on the kind of socket, but in the usual cases it is better to keep the socket unless you have very limited resources.

  • UDP is connectionless, that is you create the socket and there is no delay because of connection setup when sending a packet. But there are still system calls involved and allocating memory etc, so it is cheap but not free.
  • TCP instead needs to establish the connection before you can even start to sending data. How fast this is done depends on the latency, i.e. fast on local machine, slower in local network and even slower on the internet. Also, connection start slowly because the available bandwidth is not known yet.
  • With SSL/TLS on top of TCP connection setup is even more expensive because it needs more round trips between client and server.

In summary: If you are using TCP you almost always better keep the socket open and close it only if you lack the necessary resources to keep it open. A good compromise is to close the socket as long as you have enough activity on the socket. This is the approach usually done with HTTP persistent connections.

answered Oct 3, 2018 by anonymous2
• 4,280 points

Related Questions In IoT (Internet of Things)

0 votes
1 answer

Sending Web requests from my Web server to my IoT device

You need to start an HTTP server ...READ MORE

answered Jan 8, 2019 in IoT (Internet of Things) by nirvana
• 3,130 points
2,048 views
0 votes
1 answer

MQTT : Connection lost on MQTT subscriber to Internet of Things Server

An invalid topic "matteo" seems to be causing the ...READ MORE

answered Oct 3, 2018 in IoT (Internet of Things) by Annie97
• 2,160 points
4,581 views
0 votes
1 answer
0 votes
1 answer

Azure IoT: Message from cloud to device using Rest API

Firstly, If you get No content response(error ...READ MORE

answered Dec 31, 2018 in IoT (Internet of Things) by Upasana
• 8,620 points
1,964 views
0 votes
1 answer

Bridging an Internet Server with IoT Module

I did something similar with an IoT ...READ MORE

answered Oct 29, 2018 in IoT (Internet of Things) by anonymous2
• 4,280 points
626 views
0 votes
1 answer

Need of mqtt broker in IoT Application

This is an architectural choice. IoT applications ...READ MORE

answered Sep 21, 2018 in IoT (Internet of Things) by anonymous2
• 4,280 points
1,048 views
0 votes
1 answer

Integrate IoT device to Azure using MQTT

Today there isn't an official support for ...READ MORE

answered Sep 24, 2018 in IoT (Internet of Things) by anonymous2
• 4,280 points
2,355 views
0 votes
1 answer

Azure IoT Hub : Sending messages using Python via mqtt

The thing is that IoT Hub is not ...READ MORE

answered Jan 4, 2019 in IoT (Internet of Things) by Upasana
• 8,620 points
3,736 views
0 votes
1 answer

Publishing commands to device in IBM IoT using MQTT in Java

If you are publishing from an application, ...READ MORE

answered Jul 27, 2018 in IoT (Internet of Things) by anonymous2
• 4,280 points
1,462 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP