Beach Cleaning Robot Blog

redis pub/sub with websockets - part III

Date: 2021-02-13
Author: Andrew

Worked out what caused yesterday’s camera problem. I'm not very smart. You may have read in one of the recent blog pages that I set up a service to run the Flask server on start up. Did I remember this? Of course not. I was trying to start the camera when it had already been started when the Flask server started. Thus the error. Once I realised this there was a definite facepalm moment.

With the server service now disabled on start up back to trying to get the redis pub/sub working to the web page.

Firstly, was to get the redislistner included in the server code. Not too much trouble there but then it becomes a blocking piece of code that stops the server doing its thing so it needs to be run in a thread. A bit more playing around and got that working as well. I had the listener echoing to the screen with the ram service working in the background while being able to still hit the web server.

Where I got stuck is working out a way to route the message from the listener script to the websocket. Tried one idea and it didn't work and ran out of time today.

Postscript: A couple of hours later I had a brainwave and I think I know how to do it... Something to try tomorrow.