What's the best approach to fetch live data from MQTT Broker via WebSockets

I’m building an IoT dashboard to show live data from certain devices and to display some metrics based on old data saved in a database.
I can’t decide between

  1. using a WebSocket in the browser to connect directly to the broker or
  2. one to connect to Phoenix and then subscribe to a certain topic in Phoenix.

I understand that the first should be faster but I’m worried about user authentication

Having the browser based functionality deal with the broker directly through the websocket commits a lot of additional complexity on the browser client.

IMO it’s better to keep the browser client lean by having it focus entirely on the management/visualization of “massaged” dashboard data rather than bogging it down with the nitty gritty details of handling raw data.

It should be far easier to deal with the “tricky stuff” on the server/in Phoenix - rather than on the browser (and should keep the dashboard viable even on lower end devices - if that is a consideration).

1 Like