Using Autobahn WebSocket for IoT Project

#1

Hello!

For quite some time now I am working on a concept for an IoT project in which I connect multiple different clients to a single server and perform task like: Grouping clients (e.g.: “Customer” / “Building”, etc), Peer-To-Peer Communications (client to server / server to single client) and some other features.

I have studied MQTT as well as the WAMP by Autobahn Application Protocols but since few features which my concept implementation defines are missing in those protocols I have to build my own application protocol. And since working with Python I came up with the idea to use the Autobahn WebSocket Framework as a “transportation / communication protocol” on which I build my application.

This application will be deployed on a higher performance server, will have a database to track clients and their states (online / offline, properties, etc.) and offer a web-interface for managing devices (web-interface separate of the WebSocket server).

These devices are clients that connect via WebSocket. The client application will be deployed on embedded linux where those devices have similar performance figure as a Raspberry Pi, for example.

When thinking about this solution and as a programmer, having WebSockets / Autobahn-Framework running on embedded devices is a pretty cool thing - at least in my mind.

I am not pretty sure if this isn’t way off autobahns topic / intention?

Also, I just stumbled over Autobahn when googling after a different WebSocket-Framework for Python. There they called their framework “passing the Autobahn test-suite”. So is Autobahn a production-ready framework that can be used in commercial product, for example?

I am looking forward for any help / advice I can get!

Thanks in advance,

Best,

Simon

0 Likes

#2

Hi Simon!

Autobahn>Python is production-ready as a WebSocket library. Mozilla use it as the basis for their browser auto push to Firefox (on the server side, naturally), so it is being used with millions of connections. The Autobahn Testsuite is a separate project which was written to test the Autobahn|Python WebSocket implementation, but is now being used across the entire industry. So I guess you can trust the library to do WebSockets well.

What exactly are your requirements for your application - and what is missing from WAMP for that? I’m asking because

a) maybe the features are there, but badly explained or hidden deep in the documentation (always a possibility),

b) it’s always interesting to learn about usage scenarios and feature requirements in the IoT space

Regards,

Alex

···

Am Sonntag, 31. Juli 2016 16:32:56 UTC+2 schrieb Simon Kemper:

Hello!

For quite some time now I am working on a concept for an IoT project in which I connect multiple different clients to a single server and perform task like: Grouping clients (e.g.: “Customer” / “Building”, etc), Peer-To-Peer Communications (client to server / server to single client) and some other features.

I have studied MQTT as well as the WAMP by Autobahn Application Protocols but since few features which my concept implementation defines are missing in those protocols I have to build my own application protocol. And since working with Python I came up with the idea to use the Autobahn WebSocket Framework as a “transportation / communication protocol” on which I build my application.

This application will be deployed on a higher performance server, will have a database to track clients and their states (online / offline, properties, etc.) and offer a web-interface for managing devices (web-interface separate of the WebSocket server).

These devices are clients that connect via WebSocket. The client application will be deployed on embedded linux where those devices have similar performance figure as a Raspberry Pi, for example.

When thinking about this solution and as a programmer, having WebSockets / Autobahn-Framework running on embedded devices is a pretty cool thing - at least in my mind.

I am not pretty sure if this isn’t way off autobahns topic / intention?

Also, I just stumbled over Autobahn when googling after a different WebSocket-Framework for Python. There they called their framework “passing the Autobahn test-suite”. So is Autobahn a production-ready framework that can be used in commercial product, for example?

I am looking forward for any help / advice I can get!

Thanks in advance,

Best,

Simon

0 Likes

#3

Hi Alex,

thank you for your fast reply! I have to say, hearing about what you say concerning Autobahn being “production ready” sounds really good! I didn’t know that Mozilla uses it.

To get a better understanding of my needs let me give you some detail about my application:

Basically we are talking about connecting multiple (100-1000) clients to a single server. These clients are smaller devices which software is running on an embedded linux system. Performance is comparable to the Raspberry Pi 1.

Those clients will “publish” values / states of their attached sensors or hardware (bridging to a microprocessor) but also “subscribe” to commands coming from the server - and which are - mostly important - for that unique client only. For example switching a unique client on or off via Web-Interface, etc.

For the “publish” part a pub/sub system will work. But I have to say that I only have been working with MQTT so far.

Beyond all this I need to group clients. For example grouping by customer - and these customers might have customers themselves - so there is a chance of adding another group. So even this might be possible with pub/sub (MQTT) but I have to add things that break the protocol a bit.

Mostly important I need that uni-directional peer-to-peer communication between client and server. And using WebSockets I am doing this with holding up a reference to all those connections and monitoring states, connected devices, etc. into a large database. This step would also be necessary using MQTT-Pub/Sub so for me there is no benefit in using Pub/Sub. All those things can also be done with WebSockets alone.

I have to admit however that after reading the tag “Pub/Sub” when studying WAMP I decided not to use it. But the Autobahn WebSocket Framework really impressed me - by reading the Code alone I can see that there was effort and quality put into.

I hope that this detail can help you making a better picture of my application. Let me know if I am totally wrong with what is WAMP. I am willing to learn and go back to it!

Last but not least (but probably better asked in a separate Post):

I am currently trying to think how to implement authentication using WebSockets only. Any advices how this can be achieved when talking about client and server being a python application and absolutely no web / http involved?

My Idea is to connect to a TLS enabled WebSocket and do the authorization based on Token / Key / Secret. But I am not pretty sure …

Best,

Simon

0 Likes

#4

Hi Simon,

I have studied MQTT as well as the WAMP by Autobahn Application Protocols
but since few features which my concept implementation defines are missing

What is missing in WAMP?

Cheers,
/Tobias

0 Likes

#5

Hi Tobias,

well it’s not that there is something missing in WAMP or MQTT - I am sorry, that was a bad description. It’s more like for my specific application I need databases, grouping, etc. on top of WAMP, MQTT so I decided to start writing things from the bottom and start with WebSockets as the communication platform.

There is something else I don’t like about WAMP, MQTT or Pub/Sub in general (in relation to my specific application). Take the following example:

I am offering a platform for my customers so that they can register their devices and allow monitoring of states, one-to-one communication and setting states. These customers have customers themselves which use devices made by my customer. So the resulting address scheme would be:

myportal/mycustomer/theircustomer/device/

The only problem I see in here is that my customers customer could exchange values in the string (or identifier in WAMP like “com.myportal.mycustomer.theircustomer.device.state”) and access other customers devices. With using my own protocol / implementation based on WebSockets I know a way how to prevent this.

In MQTT or WAMP I could imagine hashing plain-text customer identifiers. I didn’t knew about the WAMP - CRA which you pointed out in my other post - I will take a look since WAMP really looks more promising that MQTT - at least for using it in my specific application

Thanks,

Best,

Simon

···

On Monday, August 1, 2016 at 8:45:09 AM UTC+2, Tobias Oberstein wrote:

Hi Simon,

I have studied MQTT as well as the WAMP by Autobahn Application Protocols

but since few features which my concept implementation defines are missing

What is missing in WAMP?

Cheers,

/Tobias

0 Likes

#6

Hi Tobias,

I have to admit that I was stuck in my own way of thinking and judged WAMP to fast. The more I read about WAMP the more I begin to understand what makes it so different to MQTT. The fact of loosely coupled Application Components is a pretty cool thing. Browsing through your examples I find a lot of stuff I would have to implement myself when deciding to make my own way, starting on WebSockets!

All in all I am impressed a lot! But I have to rethink my application structure first before maybe switching to WAMP.

Best,

Simon

···

On Monday, August 1, 2016 at 8:45:09 AM UTC+2, Tobias Oberstein wrote:

Hi Simon,

I have studied MQTT as well as the WAMP by Autobahn Application Protocols

but since few features which my concept implementation defines are missing

What is missing in WAMP?

Cheers,

/Tobias

0 Likes

#7

Hi Simon,

in WAMP, realms can be used for multitenant applications. These are completely separate routing namespaces, and access can be controlled of course. Within 1 realm, you can also control access to URIs fine grained (authorization). etc etc

Using WebSocket URLs for tenants is not a viable way .. you'll bind yourself to the specifics of 1 transport (WebSocket). Eg Crossbar.io can talk WAMP over different transports (namely, WebSocket, RawSocket and Longpoll).

Also: there is a difference between authentication ("who is it?") vs authorization ("what is allowed given who").

Anyways: don't reinvent the wheel without necessity;)

Cheers,
/Tobias

···

Am 01.08.2016 um 10:10 schrieb Simon Kemper:

Hi Tobias,

well it's not that there is something missing in WAMP or MQTT - I am sorry,
that was a bad description. It's more like for my specific application I
need databases, grouping, etc. on top of WAMP, MQTT so I decided to start
writing things from the bottom and start with WebSockets as the
communication platform.

There is something else I don't like about WAMP, MQTT or Pub/Sub in general
(in relation to my specific application). Take the following example:

I am offering a platform for my customers so that they can register their
devices and allow monitoring of states, one-to-one communication and
setting states. These customers have customers themselves which use devices
made by my customer. So the resulting address scheme would be:

myportal/mycustomer/theircustomer/device/

The only problem I see in here is that my customers customer could exchange
values in the string (or identifier in WAMP like
"com.myportal.mycustomer.theircustomer.device.state") and access other
customers devices. With using my own protocol / implementation based on
WebSockets I know a way how to prevent this.

In MQTT or WAMP I could imagine hashing plain-text customer identifiers. I
didn't knew about the WAMP - CRA which you pointed out in my other post - I
will take a look since WAMP really looks more promising that MQTT - at
least for using it in my specific application

Thanks,

Best,

Simon

On Monday, August 1, 2016 at 8:45:09 AM UTC+2, Tobias Oberstein wrote:

Hi Simon,

I have studied MQTT as well as the WAMP by Autobahn Application

Protocols

but since few features which my concept implementation defines are

missing

What is missing in WAMP?

Cheers,
/Tobias

0 Likes