lawik
TIL: Accessing a Nerves device from Livebook
I don’t know why I did not try this sooner:
System.cmd("epmd", ["-daemon"])
Node.start(:"nerves@#{Toolshed.hostname()}.local")
Node.set_cookie(:mycookie)
And voíla you can connect the regular Livebook app to your device as an attached node and you can run and re-run entire experiments over and over again.
The fact that you keep your livebook can make this a fair bit more practical than the IEx session I use so much during Nerves development.
Need to try it with some sensors and graphs as well.
When I mentioned this on Slack Frank brought up the need for port forwarding on NervesHub so you can connect to you devices. That would be quite rad and I need to read more about wireguard ![]()
I imagine this would allow having runbooks for checking the status of a device. Fixes for known problems. That kind of stuff. And of course working with a specific troubled device over time. Without pasting stuff over and over.
Any other ideas about how to use it?
Most Liked
jonatanklosko
For completeness, depending on the use case, you can also use the “Remote execution” smart cell. This should remove restriction on Elixir version compatibility between Livebook and the Nerves device. Also, this way you can offload some computation to the local machine, and you can bring extra dependencies for charting data and whatnot. Finally, it has a lower footprint, because attaching Livebook temporarily loads some Livebook-specific modules into the node, whereas the cell only does an :erpc call : )
lawik
Not quite. Nerves provides SSH into IEx.
NervesHub provides IEx terminal in the browser over WebSocket without needing a direct network path from you to the device. Device connects to NervesHub over WebSocket. You connect to NervesHub via browser. Meaning free NAT traversal and so on but no general networking.
Two similar features but quite different.
lawik
SSH remote tunnels were a blessing for me on restricted networks in my teens. I could expose any port I liked if could SSH to my home server and my home server ran SSH on port 443.
Not ehat I would do for a good dev flow with Livebook and Nerves though. Maybe some nice MNDP (mndp | Hex) for discovery which I guess could work over Wireguard. (Edit: seems like Wireguard does not support broadcast/multicast so no discovery)
Popular in Discussions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance








