[rabbitmq-discuss] rabbitmq-mochiweb

Benjamin Polidore polidore at gmail.com
Sun Apr 18 19:31:12 BST 2010

Thanks, Paul.  I decided not to mess with the source code, and I'm just
using OS X's built in apache for my static files.

Now I'm getting a different problem. I modified the test program to work in
this new context by changing the paths for loading the javascripts and
changing the urls in rabbitmq.js:

    factoryServiceUrl: *"http://h5pro.local:55672/rpc/rabbitmq",*
  rpcServiceUrlBase*: "http://h5pro.local:55672/rpc/",*

and in test.js:

    var channelFactory = new JsonRpc.Service("*
http://h5pro.local:55672/rpc/rabbitmq", *

But it doesn't work.  When I do an ngrep on the traffic going between my js
and mochiweb, I get:

T -> [AP]
  OPTIONS /rpc/rabbitmq HTTP/1.1..Host: h5pro.local:55672..Connection:
keep-alive..User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_3; e
  n-US) AppleWebKit/533.4 (KHTML, like Gecko) Chrome/5.0.375.9
  -Control-Request-Method: POST..Origin:
X-Requested-With, Content-Type, Accept..Accept: */*..
  Accept-Encoding: gzip,deflate,sdch..Accept-Language:
en-US,en;q=0.8..Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3....

T -> [AP]
  HTTP/1.1 200 OK..Server: MochiWeb/1.0 (Any of you quaids got a
smint?)..Date: Sun, 18 Apr 2010 18:27:48 GMT..Content-type:
  ength: 155....

T -> [AP]
not found","error":["http://h5pro.local:55672/rpc/rabb  itmq",""]}}    *
*Thoughts?       *
bp        *

On Sat, Apr 17, 2010 at 6:46 PM, Paul Jones <pauljones23 at gmail.com> wrote:

> Hi Benjamin,
> In the production mode, mochiweb doesn't really have a docroot setup.
> /rabbitmq_lib will serve the files in priv/www, but that is as far as it
> goes.
> However... if you want to serve some other files then you could always use
> code similar to what the test mode does to make it happen. For example, if
> you were to add:
> Handler = rabbit_mochiweb:static_context_handler("", ?MODULE,
> "priv/mydocroot"),
> ok = rabbit_mochiweb:register_global_handler(Handler),
> after the line:
> rabbit_mochiweb:register_static_context(ContextRoot, ?MODULE, "priv/www")
> in src/rabbit_jsonrpc_channel_app.erl, then once you've installed the
> plugin into Rabbit, any file put into
> priv/plugins/rabbitmq-jsonrpc-channel/priv/mydocroot should be served from
> the root context of mochiweb.
> BTW, I've just noticed a bug in the packaging of the jsonrpc-channel plugin
> such that if you do run that plugin by installing it via a .ez, you'll need
> to copy the priv/www directory into
> priv/plugins/rabbitmq-jsonrpc-channel/priv/www (otherwise libraries such as
> rabbitmq.js won't be available).
> Thanks,
> Paul.
> On Sat, Apr 17, 2010 at 11:29 PM, Benjamin Polidore <polidore at gmail.com>wrote:
>> Hey, paul, I installed all the dependencies to rabbitmq-jsonrpc-channel
>> (see below).
>> I see that you add a little context in test mode.  Basically, I was hoping
>> to use the plugin to host my HTML and javascript in dev mode so I don't have
>> to run another webserver on my laptop.  I prefer to run rabbitmq in
>> "production" mode on my laptop, and I was curious what mochiweb thinks the
>> docroot is in this mode.
>> [{running_applications,
>>      [{rabbit_jsonrpc_channel,"RabbitMQ JSON-RPC Channels","0.01"},
>>       {rabbit,"RabbitMQ","1.7.2"},
>>       {os_mon,"CPO  CXC 138 46","2.2.5"},
>>       {sasl,"SASL  CXC 138 11","2.1.9"},
>>       {rabbit_jsonrpc,"Rabbit JSON-RPC","0.01"},
>>       {rfc4627_jsonrpc,"JSON RPC Service","0.01"},
>>       {rabbit_mochiweb,"RabbitMQ Mochiweb Embedding","0.01"},
>>       {mochiweb,"MochiMedia Web Server","0.01"},
>>       {mnesia,"MNESIA  CXC 138 12","4.4.13"},
>>       {stdlib,"ERTS  CXC 138 10","1.16.5"},
>>       {kernel,"ERTS  CXC 138 10","2.13.5"}]},
>>  {nodes,[rabbit at H5Pro]},
>>  {running_nodes,[rabbit at H5Pro]}]
>> ...done.
>> On Sat, Apr 17, 2010 at 4:11 PM, Paul Jones <pauljones23 at gmail.com>wrote:
>>> Hi Benjamin,
>>> Which plugins have you installed into RabbitMQ? The mochiweb plugin alone
>>> simply embeds a webserver - you'll need to install rabbitmq-jsonrpc and
>>> rabbitmq-jsonrpc-channel to get the JSON services.
>>> If you have done this, then you might be hitting the fact that when
>>> running under test, an additional context is installed under the root that
>>> provides all the various test examples. We don't activate this in the
>>> "production" mode, since we don't expect you'll want them in a real
>>> deployment. The scripts for doing JSON-RPC are still there though - under
>>> /rabbitmq_lib (the scripts that are made available via this can be found on
>>> the filesystem in priv/www).
>>> I hope this answers your question.
>>> Cheers,
>>> Paul
>>> On Sat, Apr 17, 2010 at 8:28 PM, Benjamin Polidore <polidore at gmail.com>wrote:
>>>> hi, i'm trying to use the json-channel plugin, and it runs ok when i do
>>>> make test, but it doesn't seem to work when i try to start up my broker.
>>>>   the port is open, but everything returns 404.  what is mochiweb using
>>>> as a docroot when I run it outside make test?  sorry if this is obvious, but
>>>> i've been struggling with it for a couple hours.
>>>> thanks,
>>>> bp
>>>> _______________________________________________
>>>> rabbitmq-discuss mailing list
>>>> rabbitmq-discuss at lists.rabbitmq.com
>>>> http://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20100418/acc783e0/attachment.htm 

More information about the rabbitmq-discuss mailing list