Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [paho-dev] Binding MQTT to REST servers using Link: rel="mqtt"

David,

I'm going to have to do some reading up before I can answer your question.  Perhaps someone else will step in before then.

Ian

On 05/07/14 16:03, David Janes wrote:
I've been working quite a bit with RESTful webservices and MQTT recently. One annoying gap of REST interfaces is there's no clear / simple / natural way to work notifications into the paradigm. For example, consider this resource


This is very well behaved from a REST point of view. It can handle GET and PUT (and I think PATCH) requests to retrieve and modify state. However, if the state is modified, how does someone else know this in near real time? Well, MQTT is a natural solution, but the way a developer would know this is to "read the docs". Reading the docs kinda sucks if you can make it Just Work. 

For discussion, I'm proposing a rel="mqtt" Link type that can bind REST resources to an MQTT server. For example, if you look at that resource above:

HTTP/1.1 200 OK
Date: Sat, 05 Jul 2014 14:36:37 GMT
Server: Apache/2.2.25 (Unix) DAV/2 PHP/5.2.16 mod_ssl/2.2.25 OpenSSL/0.9.8e-fips-rhel5 mod_fastcgi/2.4.6
Content-Length: 43
Access-Control-Allow-Headers: Content-Type
Link: <tcp://mqtt.iotdb.org:1883>; rel="mqtt"; payload=PUT; topic="basement/hue/1"
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET, PUT, POST
Content-Type: application/json

{
     "on": true, 
     "rgb": "#FF0000"
}

The Link: header says that there's an associated MQTT resource available, that broadcasts updates (payload=PUT) in JSON (the default content-type) using the topic "basement/hue/1". Deeper documentation is available here:


And a really lousy diagram of what this looks like right here:


Your feedback is appreciated.

Regards,
David


_______________________________________________
paho-dev mailing list
paho-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/paho-dev


Back to the top