[ejabberd] Error: REST request is rejected by service

David Cunningham dcunningham at voisonics.com
Wed Jul 27 14:31:29 MSK 2016


Hi James,

Thank you, that works a treat. Good to have the required configuration
documented!


On 26 July 2016 at 20:10, James Tait <james.tait at wyrddreams.org> wrote:

> On 25/07/16 13:08, David Cunningham wrote:
>
> Thanks James and Badlop for the replies.
>
> I get the same response when using the wget as Badlop suggested. Wget
> provides an Accept header of "Accept: */*", and it doesn't work if I force
> it's header to "Accept: application/xml".
>
> Right, I had a play around and it looks like the module completely ignores
> the Accept header.
>
>
> Here's the ejabberd log with debug level set:
>
> 2016-07-25 03:43:18.349 [info] <0.577.0>@ejabberd_listener:accept:333
> (#Port<0.18713>) Accepted connection XX.XX.246.78:42376 -> XX.XX.246.78:5285
> 2016-07-25 03:43:18.349 [debug] <0.597.0>@ejabberd_http:init:154 S:
> [{[<<"rest">>],mod_rest}]
> 2016-07-25 03:43:18.349 [info] <0.597.0>@ejabberd_http:init:158 started:
> {gen_tcp,#Port<0.18713>}
> 2016-07-25 03:43:18.349 [debug] <0.597.0>@ejabberd_http:process_header:281
> (#Port<0.18713>) http query: 'POST' <<"/rest">>
> 2016-07-25 03:43:18.349 [debug] <0.597.0>@ejabberd_
> http:extract_path_query:395 client data: <<"<presence to=\"david at foo.com\"
> from=\"dcunningham at foo.com\"><status>On the phone</status></presence>">>
> 2016-07-25 03:43:18.349 [debug] <0.597.0>@ejabberd_http:process:353
> [<<"rest">>] matches [<<"rest">>]
> 2016-07-25 03:43:18.349 [debug] <0.597.0>@mod_rest:process:55 Error when
> processing REST request:
> Data: <<"<presence to=\"david at foo.com\" from=\"dcunningham at foo.com\"><status>On
> the phone</status></presence>">>
> Error: {badmatch,false}
>
> I've done a lot of playing with the configuration but can't get past this
> "406 Not Acceptable" problem. Any advice appreciated.
>
>
> What I’ve discovered is:
>
>    - The module has to be configured in a virtual host.
>    - The name of the virtual host has to match the hostname in the Server
>    header of the request.
>    - The allowed_ips can be the literal string "all", or a list of IP
>    addresses as strings.
>
> So something like this should work:
>
> listen:
>   -
>     port: 5285
>     module: ejabberd_http
>     request_handlers:
>       "/rest": mod_rest
> host_config:
>   "myhost.mydomain":
>     modules:
>       mod_rest:
>         allowed_ips:
>           - "192.168.0.1"
>
> And then the request:
>
> curl http://myhost.mydomain:5285/rest -v -d '<message to="you at myhost.mydomain" <you at myhost.mydomain> from="me at myhost.mydomain/rest" <me at myhost.mydomain/rest>><body>Hello World</body></message>'
>
> HTH,
>
> JT
>>
> --
> ---------------------------------------+--------------------------------
> James Tait, BSc                        |    xmpp:jayteeuk at wyrddreams.org
> Programmer and Free Software advocate  |        Tel: +44 (0)870 490 2407
> ---------------------------------------+--------------------------------
>
>
>
> _______________________________________________
> ejabberd mailing list
> ejabberd at jabber.ru
> http://lists.jabber.ru/mailman/listinfo/ejabberd
>
>


-- 
David Cunningham, Voisonics
http://voisonics.com/
USA: +1 213 221 1092
Australia: +61 (0) 2 8063 9019
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.jabber.ru/pipermail/ejabberd/attachments/20160727/79fb8418/attachment.html>


More information about the ejabberd mailing list