From Our Blogs
First of all,
Welcome to my blog, this is a space I intend to keep as a technical diary,
Please comment, this is my first post so any feedback is appreciated (:
I have a new project that needs realtime synchronization between mobile devices , server, and front end web clients…
It’s not the first time I see this punk coming…
I have built some apps that have had this interesting problem in common:
How to share state between players?
- A mobile app that knows when a shift is taken in a timesheet solution.
- A mobile/desktop app that pops up an alert to call for assistance on a library.
- A solution to lock the gate on my house remotely while on my way to work.
I have implemented these things in the past:
- Web sockets, chat style
- Broker model with RabbitMQ
Now a new project needs realtime again,
I looked for a framework, pattern or SOA that could be more scalable, and easy to implement across multiple devices,
So happily there are a lot of options here.
Lots of intelligent people have had to deal with this technical problem which is just like the shirtless bully asking to be knocked out.
Please let me know if there is something easier, or more powerfull.
After investigating the issue WAMP.ws is my current weapon of choice.
Now, to get back to the problem,
This problem is called realtime web, but covers mobile and IoT.
The definition of realtime on wikipedia is very enlightening:
“The real-time web is a network web using technologies and practices that enable users to receive information as soon as it is published by its authors, rather than requiring that they or their software check a source periodically for updates”
This is the stack for my solution
Mobile: Android, iOS
Backend: Node.js, Angular/React
IoT: Arduino, Pi [Wish list!!]
With the big constraint of keeping it cheap/free and “Real”
The idea of a chat is good, where messages are updated on your screen,
or a chess game, where your screen is updated with your rival’s moves…
in real time,
Now, this is the body of the next rant…
- Available on market
- My preferred solution… WAMP.ws
- Explore Tools, Explore other solution for IoT
Lets talk about your MOM [Message oriented middleware]
Again from wiki: “Message-oriented middleware (MOM) is software or hardware infrastructure supporting sending and receiving messages between distributed systems. MOM allows application modules to be distributed over heterogeneous platforms and reduces the complexity of developing applications that span multiple operating systems and network protocols. ”
And all that Jazz, if you want to read more on the subject it’s very interesting.
It’s where i went on my first round with the keep it real punk,
I used RabbitMQ, that works with the AMQP [Advanced Message Queuing Protocol (AMQP)]
- uses channels
- can be used by multiple applications
- point to point
- pub sub, broadcast
This was an ok experience, I was using this RabbitMQ broker with a PHP back end [The Joy!] and an iPad client [running a local server to receive updates from the rabbit].
I was happy Rabbit existed, but found its Erlang source a little bit intimidating,
“Open-Standard Business Messaging in 5000 lines of Erlang”
So even when my new found love is on functional programming [Rants coming soon on Swift], and I have spent blind dates in the alley with Haskell…
There was a very slim chance of me getting to look at the black box…
Then I took it more 101 and reconnected my Sockets, [fan of sockettes also]
Here’s my brief:
- HTTP [half duplex]: one way, request response, polling/long polling
- webSockets [full duplex]: two way, html5
This is a big problem as mobile apps use web services, if we keep it in web services on HTTP we have to do solutions like having an internal server for each ipad connected to the system, and having the back end sending a GET or POST to those ipads, changing IPs every time the app opened, and handling adhoc messages.
Then we have websockets, now on the HTML5 spec, and in the infrastructure from the begining, See the OSI model above the TCP layer… more on this
But not all is perfect with sockettes,
and some times you can do without sockets.
Here a nice example of iOS/Android updating with webSockets
But the show most go on, now some solutions are available …
Available on market
I found many good contenders on Vendors and Patterns…
This article is the best summary
And from the same guy at pusher: Choosing your Realtime Web App Tech Stack
A list of vendors of MOMs as SOAs sounds nasty! on this quora question
So, they offer hosted and self hosted solutions, I will study the leading ones and report on another blog if I find something of interest for the convergence of IoT.
My problem is I want something cheap/free, and these guys are not…
Which brings me to frameworks/patterns,
And dealing with realtime and websockets,
Many opinions here but the one I like is an abstraction layer “Primus” that lets you deal logically with what you want to do, and use any framework to deal with your sockets like socket.io
Primus code examples for mobile clients
My preferred solution is WAMP.ws for these reasons:
- language agnostic
- it’s a registered standard
- pubSub + RPC
- web native
One problem with hosting this solution myself, is scalability, but when I see this benchmark data about performance, I think it’s a Lambo problem…
if you have a problem with having a lambo, you can handle it…
There is WAMP v1 and WAMP v2,
I’m just going to use the v2,
For v1 you have clients like Autobahn … Open-source real-time framework for Web, Mobile & Internet of Things.
on WAMP V2, there are many clients and routers to choose from,
I tested these ones on my required platforms;
and my own implementation of using WAMP jawampa for java on android using gradle makes it very easy I must say!
A funny thing is that I moved away from Django, as I found the whole async, non blocking experience annoying on Django/Python,
So I moved to Node,
Now to deal with this realtime punk use the crossbar.io “reactor” , it’s written on Python using twisted… how funny!
There are reactors in pure node also.
Ok, I will be making more blogs about WAMP.ws, and tutorials on my experience with mobile, arduino, node, ping ball machine…
. Sony built an IoT framework for android based on WAMP
Explore Tools, Explore other solution for IoT
- nice echo example webSocket
- websocket trafic inspection on Chrome browser
- check this for socket inspection https://www.wireshark.org/
- Charles proxy supposed to work not yet working for me… why?
Explore another solution for IoT
Use CoATT, MQTT!
More info: IoT protocols
realtime operating sys