0

I know the question I am going to ask is a bit duplicate. But, I am still asking as I want to know the latest technologies and I am a bit lost after researching for a few hours.

I have a Raspberry Pi logging real-time temperature and humidity. Now, I am writing a flask app to push these data to clients who (subject to rights) will be able to observe continuously without refreshing the dashboard/page.

What will be the best option to make an efficient system, keeping in mind that there will be multiple sensors in the future? The options I find:

  • Ajax
  • WebSocket
  • Framework e.g. bokeh or dash
  • MQTT

Please give me your opinions.

1 Answer 1

1

Good choice if you want to write your backend using Python is:

Server: Flask with Sokcet.IO + InfluxDB for real-time data storing

Frontend: Some JS framework or pure Js + websocket


UPD (this message is too long to post it to comments):

https://www.smashingmagazine.com/2018/02/sse-websockets-data-flow-http2/

The thing is that I'm not talking that websocket is the right solution for all possible cases/problems and should be used everywhere. Obviously it's depends on your needs and your project architecture. I think that article can help you to make a choice: if your app architecture requires full-duplex browser-server connection - you can use websocket for this and that will work for you, but if your frontend requires only one-way data send direction - from server to browser - you can use SSE, as the article says about SSE: "our main flow of data is from the server to the client and in much fewer occasions from the client to the server". To sum it up, you need to think about your application architecture and about how data needs to be sent between browser and server to choose right technology. Also, if you don't want to use neither websocket nor SSE - you can use ajax to pull data from server and that will also work for you.

Sign up to request clarification or add additional context in comments.

2 Comments

Hi Artsiom, thanks a lot for your answer. I was implementing socket.io, but later I found this article smashingmagazine.com/2018/02/sse-websockets-data-flow-http2 which suggesting Server-Sent-Event. Now, i am confused, as I don't know much about networking and protocols. Can you please tell me more why socket.io will be better? Regsards Hossain
@CognitiveRobot please see UPD. if you find my post helpful - please mark it as an answer. thanks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.