Great work Kevin, I am creating a time track and attendance system using RFID and Barcode over multiple clients. This gives me the confidence to proceed as I can now see a way to grasp the data. Thank you.
So socketio isn't really a request/response scenario. It is event driven with a broadcast approach. For example, when the server gets the "mymessage" event you could send a message back out to the clients using "emit" on the server. That is a way to emulate a request/response flow. Beware, however, that when you emit from the server all clients will get the message so you will want to add some metadate to identify the client so only the appropriate client processes the message. Hopefully that helps.
This would be a good solution if you only need a passive server receiving the requests. What if we want to send and receive some data from both sides (maybe using hostname or whatever)?
You can go both ways with socketIO although it gets a little involved. You just emit from the clients but you could also use raw sockets (TCP or UDP) and have the clients connect directly to the server with a two-way pipe.
Yeah, absolutely. Just remember that with socket.io the messages are broadcast to all clients but you can certainly have clients on RPi zeros as well as on your computer.
Hello Kevin ! This demo was very helpful for a project that I am working on right now. I have the same setup but with another additional angular web application component to display the data in real time as well. At the moment I am using a flask server with socketio. So I can communicate with both Pi and Web app using websockets. Do you have any suggestion for any alternate or better way ?
Hey Lahiru, thanks for watching. That sounds like a cool project. One of the nice things about socketio is that you can add additional listening clients easily. Sounds like you're on the right track to me by just having that angular app get it's data via socketio as well like the Pis and server. If you wanted you could have the app get data by calling endpoints you create on the flask server but it's really just a matter of preference. Good luck on your project.
Thanks for watching Grezz. Socketio is a broadcast messaging system so it sends the message to all of the clients but you can do things within the messages to target specific clients. Using unique ids for example in the message so that other clients can ignore it. But as far as I understand you have to add that functionality yourself in code.
Socketio is a broadcast messaging system so it sends the message to all of the clients but you can do things within the messages to target specific clients. Using unique ids for example in the message so that other clients can ignore it. But as far as I understand you have to add that functionality yourself in code. So you would just emit the message from the server and all clients would see it.
@@KevinSidwar Thank you very much for your clarification. I am trying to emit a message from the server, but no message has been received by any client, would you plz help me in solving this matter!
Kevin, thanks for this video! I am making a simple distributed system with 4 rasp pis for my graduate OS class. This is a great intro to sockets in python. Do you have more videos on this topic?
Thanks so much for watching Emily. Glad you found it helpful. I don't really have any other videos around Pi to Pi communication or sockets. Sorry. Good luck on your class project!
Insterd of Deleting "threading.current_thread() == threading.main_thread()" you could update it to threading.current_thread().__class__.__name__ == '_MainThread'
Hi, thanks for the video! Is there any way when my server goes down and then start again of my raspberryPi connects automatically? For example, if Pi lost connection to the server, it will tries to connect to it in 5 seconds interval
Thanks for watching the video. You could use cron to automatically start the process when the Pi boots up. The WiFi issue might be a little trickier. You might just add something within the Python program that checks for connectivity. I'm not really sure how the socket.io library handles interruptions to network service. You'd have to look into that to come up with a plan to deal with it.
Hello Thank you for this great tutorial How can I connect a Raspberry Pi to every room in Django Channel chat app? Thank you very much for your tutorial
Sorry, I'm not familiar with Django but you should be able to use the same approach and make connections for each room and just send that information along.
Hi, Thanks a lot. Really Good video and able to understand and connect the RPi's . I want to connect server Pi with remote client PI and need to send and receive the data. Could you please help me to solve this?
Thank you for this tutorial, I really appreciate it. Just exploring the world of MQTT and IoT and this provided me with the guidance I was looking for! However, I am having trouble when going to run my server.py script. I have an issue like the bug you showed above, but mine is a ModuleNotFoundError for the import of _ssl. I am running Python 3.7.0 and I have tried everything I have been able to find online and nothing has worked. Any ideas?
Hey Gabriella, thanks for watching. That sounds like an issue with missing a system library. If you are on the Raspberry Pi try install the SSL stuff with sudo apt-get install libssl-dev. Let me know if you're still stuck.
Great work Kevin, I am creating a time track and attendance system using RFID and Barcode over multiple clients. This gives me the confidence to proceed as I can now see a way to grasp the data. Thank you.
So glad it was helpful.
Is there a way to log the response or information return by the server on the client?
So socketio isn't really a request/response scenario. It is event driven with a broadcast approach. For example, when the server gets the "mymessage" event you could send a message back out to the clients using "emit" on the server. That is a way to emulate a request/response flow. Beware, however, that when you emit from the server all clients will get the message so you will want to add some metadate to identify the client so only the appropriate client processes the message. Hopefully that helps.
@@KevinSidwar Absolutely thank you and great video.
This would be a good solution if you only need a passive server receiving the requests. What if we want to send and receive some data from both sides (maybe using hostname or whatever)?
You can go both ways with socketIO although it gets a little involved. You just emit from the clients but you could also use raw sockets (TCP or UDP) and have the clients connect directly to the server with a two-way pipe.
can i use socket.io to communicate between multiple RPi zeros and my computer?
Yeah, absolutely. Just remember that with socket.io the messages are broadcast to all clients but you can certainly have clients on RPi zeros as well as on your computer.
Hello Kevin ! This demo was very helpful for a project that I am working on right now. I have the same setup but with another additional angular web application component to display the data in real time as well. At the moment I am using a flask server with socketio. So I can communicate with both Pi and Web app using websockets. Do you have any suggestion for any alternate or better way ?
Hey Lahiru, thanks for watching. That sounds like a cool project. One of the nice things about socketio is that you can add additional listening clients easily. Sounds like you're on the right track to me by just having that angular app get it's data via socketio as well like the Pis and server. If you wanted you could have the app get data by calling endpoints you create on the flask server but it's really just a matter of preference. Good luck on your project.
@@KevinSidwar Thank you for the feedback. Appreciate it !
Hey Kevin. Great video. Is it possible to have multiple clients connected, then use the server to select just one to send a message or file to?
Thanks for watching Grezz. Socketio is a broadcast messaging system so it sends the message to all of the clients but you can do things within the messages to target specific clients. Using unique ids for example in the message so that other clients can ignore it. But as far as I understand you have to add that functionality yourself in code.
Hi Kevin, thank you for this helpful tutorial.
Would you plz tell me how I could send from server to client
Socketio is a broadcast messaging system so it sends the message to all of the clients but you can do things within the messages to target specific clients. Using unique ids for example in the message so that other clients can ignore it. But as far as I understand you have to add that functionality yourself in code. So you would just emit the message from the server and all clients would see it.
@@KevinSidwar Thank you very much for your clarification. I am trying to emit a message from the server, but no message has been received by any client, would you plz help me in solving this matter!
@@ranariad If you can post of Gist of your code I could take a look.
Kevin, thanks for this video! I am making a simple distributed system with 4 rasp pis for my graduate OS class. This is a great intro to sockets in python. Do you have more videos on this topic?
Thanks so much for watching Emily. Glad you found it helpful. I don't really have any other videos around Pi to Pi communication or sockets. Sorry. Good luck on your class project!
Insterd of Deleting "threading.current_thread() == threading.main_thread()" you could update it to threading.current_thread().__class__.__name__ == '_MainThread'
Thanks for sharing that here Amit. Hopefully it will help those that see the video.
Hi, thanks for the video!
Is there any way when my server goes down and then start again of my raspberryPi connects automatically? For example, if Pi lost connection to the server, it will tries to connect to it in 5 seconds interval
Thanks for watching the video. You could use cron to automatically start the process when the Pi boots up. The WiFi issue might be a little trickier. You might just add something within the Python program that checks for connectivity. I'm not really sure how the socket.io library handles interruptions to network service. You'd have to look into that to come up with a plan to deal with it.
Hello
Thank you for this great tutorial
How can I connect a Raspberry Pi to every room in Django Channel chat app?
Thank you very much for your tutorial
Sorry, I'm not familiar with Django but you should be able to use the same approach and make connections for each room and just send that information along.
Hi,
Thanks a lot. Really Good video and able to understand and connect the RPi's . I want to connect server Pi with remote client PI and need to send and receive the data. Could you please help me to solve this?
I think there is a way to do this that involves router settings and DNS services but I'm not sure how to do it. Sorry that's not more helpful.
Thank you for this tutorial, I really appreciate it. Just exploring the world of MQTT and IoT and this provided me with the guidance I was looking for! However, I am having trouble when going to run my server.py script. I have an issue like the bug you showed above, but mine is a ModuleNotFoundError for the import of _ssl. I am running Python 3.7.0 and I have tried everything I have been able to find online and nothing has worked. Any ideas?
Hey Gabriella, thanks for watching. That sounds like an issue with missing a system library. If you are on the Raspberry Pi try install the SSL stuff with sudo apt-get install libssl-dev. Let me know if you're still stuck.