8

I'm currently on a project in which we will be communicating between a household appliance (e.g. an oven) with an embedded computer, and a mobile device (phone). Here's a brief summary of the setup:

  • The embedded device will be running Java, must likely on Android but possibly some variant of Linux
  • The mobile device will be running C# (through Xamarin) on iOS or Android.
  • Communication will occur over the internet when the user is not at home, so we need some sort of proxy server to route the messages between the mobile device and the appliance (to circumvent NAT firewalls, etc). I am more or less agnostic to server language/platform
  • However, when the user is at home and connected to their Wifi network, we would like communication to occur directly between the appliance and the phone over the LAN, just in case the server is not reachable for some reason. I would imagine this would mean that the appliance has to act as a server.
  • The embedded device will be giving the phone "real time" (about every 1-5 seconds) updates about certain data points (e.g. temperature). We may have up to a few thousand clients hitting the proxy server. This is basically a publish/subscribe pattern
  • The phone should be able to send action requests to the appliance (e.g. turn on/off, set temperature), and the appliance should be able to respond with a success/fail message. This is basically an RPC pattern

Are there any frameworks out there that support realtime communication over the internet and LAN, publish-subscribe and RPC, and run on both both Java and C#? I have a few good candidates but I especially see no way to share protocols between communicating over the internet and communication over the LAN (is this even possible?). My current shortlist consists of (in order):

  1. RabbitMQ -- Supports all major platforms, authentication/SSL/PubSub/RPC built in, but I don't see any way to make the two devices talk over a LAN if there is no internet connection if we are running Android appliance-side
  2. A websocket framework such as SignalR, XSockets, AutoBahn, or Socket.IO. These are either not cross-platform between .Net and Java (XSockets/AutoBahn) or we run into the LAN problem above (SignalR)
  3. ZeroMQ -- this looks conceptually doable, but it looks quite low-level and looks like you have to re-invent the wheel quite a bit to get even basic PubSub w/ heartbeat monitoring going.
  4. Doing one of the above over the internet and home-brewing some protocol over raw sockets for communication over the LAN (a little messy, seems like this should be a solved problem already)

XMPP also looks like it could be promising but from what I've seen the community and documentation/examples don't seem robust, I've also read that performance with XMPP is not quite real-time.

1 Answer 1

5

So, this is not really an answer (more of information) but it is to long for the comment field.

Sounds like a fun project! I can only speak for XSockets but I am sure that someone else will fill in the blanks for the other techs.

Since XSockets has "cross-protocol" communication and allows custom protocols as plugins the communicaiton can be done between any devices that has TCP/IP.

V 4.0 is about to be released soon and will support pub/sub as well as rpc. There are clients for .NETMF, .NET 2.0, 3.5, 4.0 and iOS + Android (Xamarin) but due to the cross protocol feature you can connect raw sockets to talk to these clients if you want to.

I run the XSockets server at home on a raspberry pi and have both Arduino and Netduinos connected to it as well as an iOS client (plus a website and a console app). It works well even though it is just for fun and not a real product. I just check temperature and motion in my home as a proof of concept.


To get to your question/problem... I would go for a realtime framework not the MQ options. Most things above would be pretty straight forward with a good framework. The only quesiton is the LAN thing.. Have no experience in trying that but it should be doable, especially if you can have a realtime server on the LAN that takes over when the device comes home.

Anyway, sounds like a fun project. Best of luck!

3
  • Very interesting! I just saw your Youtube videos on custom protocols. How much work do you think it would be to add authorization and heartbeats for a custom protocol? Do you get to keep the awesome-looking statefulness if we used a custom protocol from Java?
    – w3therby
    May 6, 2014 at 3:23
  • Hi, Yes the protocol would just be the connection layer. Add proper "handshake" to the protocol if needed. After that you have state on the controller as all the other protocols. What language you use to communicate does not matter.
    – Uffe
    May 6, 2014 at 4:32
  • Ohh.. I did not answer it all. Heartbeats is built in with ping/pong (frames). Dont think it would take much time when you know your way around XSockets. Especially if you follow the messagemodel of XSockets it will be easy. If you build your own model it will still be doable, but take more time.
    – Uffe
    May 6, 2014 at 7:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.