Nats *server* on android/ios mobile

36 views
Skip to first unread message

Chuck Harrison

unread,
Jun 1, 2024, 3:05:47 PMJun 1
to nats
I am building an application using nats for interprocess messaging within a local context. I am targeting a variety of hardware environments with one or more small processors (e.g. Raspberry Pi or ESP32C class) within a device. So far this is working well deployed on a single Raspberry Pi (debian Linux) which runs the server service and a dozen client processes.

I would like to deploy the same app functions as pure mobile (android and ios). Mobile client code (I'm writing in flutter) work fine calling an external nats server. I want to host the server itself on mobile. This link suggests it should be possible: https://dev.to/karanpratapsingh/embedding-nats-in-go-19o .

This is somewhat beyond my expertise. I have zero go dev experience, junior-grade flutter experience, and am quite new to nats. (However I did quite a bit or ROS v1, Robot Operating System, development and the message-passing architecture feels very familiar.

I would love to hear that someone has already implemented nats-server on android and ios; if not, some pointers would be great!

Thanks,
Chuck

Chuck Harrison

unread,
Jun 2, 2024, 1:22:58 AMJun 2
to nats
I should have mentioned that I imagine that gomobile https://pkg.go.dev/golang.org/x/mobile/cmd/gomobile is the way to wrap the nats server into a deployable mobile app.

Jean-Noel Moyne

unread,
Jun 13, 2024, 5:56:39 PMJun 13
to nats
In general mobile devices OSes are pretty locked down and don't let you run a 'daemon' or server type process on the mobile device. Apple doesn't want you to do that because of the impact on the battery life of the device due to a process continuously running in the background (and using up the battery).
Even if you create for example an iOS app that binds to a listen TCP port and acts as a server, as soon as the app gets put in the background (which happens pretty quickly) iOS only let's it run for a short amount of time before suspending the process.
Reply all
Reply to author
Forward
0 new messages