Phoenix-Server communicates with Nerves-Client over HTTP - what are other options?

Hi there!

I have a pet project where I control a real life traffic light to show the status of a CI server. I have been joyfully overengineering this for over ten years now, using different hardware and software solutions.

At the beginning of this year I rewrote the client component from a Ruby to Nerves and last month I rewrote the server from node to Elixir. I am very happy with the result!

However, since I always replace the parts piece by piece these components used the same simple HTTP interface for almost eight years: Server provides a simple JSON API, client keeps polling it.

This works well, I was just wondering what other Elixir/OTP idiomatic options could look like? Phoenix.PubSub, MQTT, direct connection between nodes?

Happy about any feedback and ideas!

Server component
fabrik42/traffic-light-server-elixir: Configure traffic lights on Heroku, powered by Elixir and Phoenix

Client component
fabrik42/traffic-light-client-elixir: A web controlled traffic light for Raspberry PI, powered by Elixir and Nerves

1 Like

Have you looked at phoenix channels?

Thanks for the hint! I use them in combination with LiveView for an acompanying web view, but not for the Nerves client that controls the RL traffic light.

In order to use it with Nerves you suggest that I use something like Aircloak/phoenix_gen_socket_client: Socket client behaviour for phoenix channels?

Would love to try this. Is this a common approach?

1 Like

My suggestion would be to use https://github.com/mobileoverlord/phoenix_client

This is the client we use for nerves-hub

I’d say in the small sample set of apps that I know of personally, it is “common”.

2 Likes

Alright! Thank you very much! I will give this a try!

1 Like