[ejabberd] Error: REST request is rejected by service

James Tait james.tait at wyrddreams.org
Tue Jul 26 13:10:58 MSK 2016


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 <mailto:david at foo.com>\"
> from=\"dcunningham at foo.com <mailto: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 <mailto:david at foo.com>\"
> from=\"dcunningham at foo.com <mailto: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" from="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
---------------------------------------+--------------------------------

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.jabber.ru/pipermail/ejabberd/attachments/20160726/f18e9b58/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: OpenPGP digital signature
URL: <http://lists.jabber.ru/pipermail/ejabberd/attachments/20160726/f18e9b58/attachment.sig>


More information about the ejabberd mailing list