[rabbitmq-discuss] RabbitMQ and Websockets

Tim Child tim at cantemo.com
Fri Nov 5 09:16:35 GMT 2010


This puts the password in plain text if you are not using https:

> {username: 'myname', password: 'mypassword'}

Hookbox has a nice way of passing the authentication, by using a combination of the username and a session cookie.
When you authenticate with hookbox, you get a web callback passing the session cookie id with the username which of course
your web application should know about as it generated the session cookie, and can map it to the username and can then allow
or deny the request..

Downside is of course that you have to provide this mechanism in your web application.

Tim.

On 5 Nov 2010, at 09:55, Miguel Morales wrote:

> Hmm, I can think of two ways for authentication.  Appending it to the
> url (not sure if it's possible):
> var ws = new WebSocket("ws://4.2.2.2:123?username=myname&password=mypassword");
> 
> Not sure if you can properly handle errors this way.  Another way
> would be something like:
> 
> var ws = new WS(...);
> //attemp to login....
> ws.send({username: 'myname', password: 'mypassword'});
> //... check if it worked, maybe get an auth token?
> 
> 
> On Fri, Nov 5, 2010 at 1:49 AM, Tim Child <tim at cantemo.com> wrote:
>> And authentication?
>> Seems to me that you should consider some form of authentication against the
>> service, whether it is some sort of REST callback to another service or some
>> other mechanism.
>> Tim.
>> 
>> On 5 Nov 2010, at 09:00, Michael Bridgen wrote:
>> 
>> var message = new Object(); message.command = "publish";
>> 
>> message.queue = "myqueue"; message.exchange = "myexchange";
>> 
>> message.key = "mybindkey"; message.body = "hello world";
>> 
>> var message_json = JSON.stringify(message);
>> 
>> var ws = new WebSocket("ws://4.2.2.2:123"); ws.send(message_json);
>> 
>> Consuming:
>> 
>> var subscribe = new Object(); subscribe.command = "consume";
>> 
>> subscribe.queue = ...
>> 
>> ws.send(subscribe_json);
>> 
>> //wait for reply from server... ws.onopen = function(event) {
>> 
>> //handle message or error here.. }
>> 
>> How about something /really/ simple:
>> 
>> var sock = new RabbitSocket("subscribe", "myexchange");
>> sock.onMessage(function(msg) {
>>  ...
>> });
>> 
>> and perhaps more provocatively,
>> 
>> var sock = new RabbitSocket("request", "myqueue");
>> sock.send("question");
>> sock.onMessage(function(answer) {
>>  ...
>> });
>> 
>> or even
>> 
>> sock.request("question", function(answer) {
>>  ...
>> });
>> 
>> This is a bit more like how our STOMP adapter works (now, on
>> default branch[1]), and more like the much admired ZeroMQ.  I've been
>> messing around with this kind of model at
>> https://github.com/squaremo/rabbit.js#readme.
>> 
>> [1] http://hg.rabbitmq.com/rabbitmq-stomp/file/0aff7391968a/DESIGN.md
>> 
>> 
>> Michael.
>> 
>> I don't need STOMP support, the websocket plugin should just require
>> 
>> a port for communication and delegate the commands to rabbitmq.
>> 
>> On Thu, Nov 4, 2010 at 10:47 AM, Christian Legnitto
>> 
>> <clegnitto at mozilla.com>  wrote:
>> 
>> On Nov 4, 2010, at 10:26 AM, Marek Majkowski wrote:
>> 
>> On Fri, Oct 29, 2010 at 19:55, Christian
>> 
>> Legnitto<clegnitto at mozilla.com>  wrote:
>> 
>> [...] Support for WebSockets
>> 
>> * It'd be nice for there a plugin to support websockets * More
>> 
>> important for Mozilla as most tools are web-based * I have set
>> 
>> it up with orbitd, but it's a pain / another moving piece /
>> 
>> easier to uncomment a line like
>> 
>> http://activemq.apache.org/websockets.html
>> 
>> 
>> Christian,
>> 
>> I'm interested in creating a websockets plugin for Rabbit.
>> 
>> But I'm not really sure how you'd like to use it.
>> 
>> As a thing exposed to the wild internet? Or just as another
>> 
>> framing for AMQP? Or as a wire protocol for STOMP? (like this
>> 
>> thing http://jmesnil.net/stomp-websocket/doc/)
>> 
>> Or maybe you have yet another use case?
>> 
>> Cheers, Marek
>> 
>> I was thinking more like http://jmesnil.net/stomp-websocket/doc/,
>> 
>> as that's what I have been using. Of course, the more options the
>> 
>> merrier :-) I can't really provide erlang help, but I'm sure I can
>> 
>> poke the WebSocket guys here at Moz to provide any assistance
>> 
>> required on that front.
>> 
>> Thanks, Christian _______________________________________________
>> 
>> rabbitmq-discuss mailing list rabbitmq-discuss at lists.rabbitmq.com
>> 
>> https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
>> 
>> 
>> 
>> 
>> 
>> 
>> _______________________________________________
>> rabbitmq-discuss mailing list
>> rabbitmq-discuss at lists.rabbitmq.com
>> https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
>> 
>> Tim Child
>> +46 (0) 7602 17785
>> Skype: timchild
>> http://www.cantemo.com
>> CANTEMO
>> 
>> _______________________________________________
>> rabbitmq-discuss mailing list
>> rabbitmq-discuss at lists.rabbitmq.com
>> https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
>> 
>> 
> 
> 
> 
> -- 
> ~ Jeremiah:9:23-24
> Android 2D MMORPG: http://developingthedream.blogspot.com/,
> http://www.youtube.com/user/revoltingx

Tim Child
+46 (0) 7602 17785
Skype: timchild
http://www.cantemo.com
CANTEMO

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20101105/39e4f07f/attachment-0001.htm>


More information about the rabbitmq-discuss mailing list