I have been trying to configure mod_rest in my ejabberd(ver 15.0.4) server to connect it with http server(XAMPP) but after compiling and setting everything it won't get started and generates a crash reports.
mod_rest.erl is downloaded from:
crash.log
2015-06-23 19:41:44 =CRASH REPORT====
crasher:
initial call: ejabberd_http:init/2
pid: <0.455.0>
registered_name: []
exception throw: {{module_must_be_started_in_vhost,mod_rest,<<"localhost">>},[{mod_rest,try_get_option,3,[{file,"mod_rest.erl"},{line,107}]},{mod_rest,check_member_option,3,[{file,"mod_rest.erl"},{line,122}]},{mod_rest,process,2,[{file,"mod_rest.erl"},{line,51}]},{ejabberd_http,process,5,[{file,"src/ejabberd_http.erl"},{line,365}]},{ejabberd_http,process_request,1,[{file,"src/ejabberd_http.erl"},{line,449}]},{ejabberd_http,process_header,2,[{file,"src/ejabberd_http.erl"},{line,287}]},{ejabberd_http,parse_headers,1,[{file,"src/ejabberd_http.erl"},{line,203}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,237}]}]}
ancestors: [ejabberd_http_sup,ejabberd_sup,<0.37.0>]
messages: []
links: [<0.329.0>,#Port<0.3837>]
dictionary: []
trap_exit: false
status: running
heap_size: 1598
stack_size: 27
reductions: 839
neighbours:
2015-06-23 19:41:44 =SUPERVISOR REPORT====
Supervisor: {local,ejabberd_http_sup}
Context: child_terminated
Reason: {module_must_be_started_in_vhost,mod_rest,<<"localhost">>}
Offender: [{pid,<0.455.0>},{name,undefined},{mfargs,{ejabberd_http,start_link,undefined}},{restart_type,temporary},{shutdown,1000},{child_type,worker}]
error.log
2015-06-23 19:41:44.554 [error] <0.455.0> CRASH REPORT Process <0.455.0> with 0 neighbours crashed with reason: {module_must_be_started_in_vhost,mod_rest,<<"localhost">>} in mod_rest:try_get_option/3 line 107
2015-06-23 19:41:44.554 [error] <0.329.0> Supervisor ejabberd_http_sup had child undefined started with {ejabberd_http,start_link,undefined} at <0.455.0> exit with reason {module_must_be_started_in_vhost,mod_rest,<<"localhost">>} in context child_terminated
ejabberd.log
2015-06-23 19:40:41.941 [info] <0.7.0> Application lager started on node ejabberd@localhost
2015-06-23 19:40:41.958 [info] <0.7.0> Application crypto started on node ejabberd@localhost
2015-06-23 19:40:41.987 [info] <0.7.0> Application sasl started on node ejabberd@localhost
2015-06-23 19:40:41.996 [info] <0.7.0> Application asn1 started on node ejabberd@localhost
2015-06-23 19:40:41.996 [info] <0.7.0> Application public_key started on node ejabberd@localhost
2015-06-23 19:40:42.051 [info] <0.7.0> Application ssl started on node ejabberd@localhost
2015-06-23 19:40:42.071 [info] <0.7.0> Application p1_yaml started on node ejabberd@localhost
2015-06-23 19:40:42.084 [info] <0.7.0> Application p1_tls started on node ejabberd@localhost
2015-06-23 19:40:42.097 [info] <0.7.0> Application p1_xml started on node ejabberd@localhost
2015-06-23 19:40:42.124 [info] <0.7.0> Application p1_stringprep started on node ejabberd@localhost
2015-06-23 19:40:42.150 [info] <0.7.0> Application p1_zlib started on node ejabberd@localhost
2015-06-23 19:40:42.161 [info] <0.7.0> Application p1_cache_tab started on node ejabberd@localhost
2015-06-23 19:40:42.843 [info] <0.7.0> Application mnesia started on node ejabberd@localhost
2015-06-23 19:40:44.575 [info] <0.37.0>@cyrsasl_digest:start:57 FQDN used to check DIGEST-MD5 SASL authentication: my.msserver.com
2015-06-23 19:40:44.729 [info] <0.7.0> Application inets started on node ejabberd@localhost
2015-06-23 19:40:44.811 [info] <0.447.0>@ejabberd_listener:listen_tcp:194 Reusing listening port for 5285
2015-06-23 19:40:44.811 [info] <0.448.0>@ejabberd_listener:listen_tcp:194 Reusing listening port for 5222
2015-06-23 19:40:44.811 [info] <0.449.0>@ejabberd_listener:listen_tcp:194 Reusing listening port for 5269
2015-06-23 19:40:44.812 [info] <0.450.0>@ejabberd_listener:listen_tcp:194 Reusing listening port for 5280
2015-06-23 19:40:44.812 [info] <0.37.0>@ejabberd_app:start:71 ejabberd 15.04 is started in the node ejabberd@localhost
2015-06-23 19:40:44.812 [info] <0.7.0> Application ejabberd started on node ejabberd@localhost
2015-06-23 19:40:48.306 [info] <0.450.0>@ejabberd_listener:accept:304 (#Port<0.3810>) Accepted connection 127.0.0.1:54407 -> 127.0.0.1:5280
2015-06-23 19:40:48.322 [info] <0.454.0>@ejabberd_http:init:155 started: {gen_tcp,#Port<0.3810>}
2015-06-23 19:41:44.553 [info] <0.447.0>@ejabberd_listener:accept:304 (#Port<0.3837>) Accepted connection 127.0.0.1:54436 -> 127.0.0.1:5285
2015-06-23 19:41:44.553 [info] <0.455.0>@ejabberd_http:init:155 started: {gen_tcp,#Port<0.3837>}
2015-06-23 19:41:44.554 [error] <0.455.0> CRASH REPORT Process <0.455.0> with 0 neighbours crashed with reason: {module_must_be_started_in_vhost,mod_rest,<<"localhost">>} in mod_rest:try_get_option/3 line 107
2015-06-23 19:41:44.554 [error] <0.329.0> Supervisor ejabberd_http_sup had child undefined started with {ejabberd_http,start_link,undefined} at <0.455.0> exit with reason {module_must_be_started_in_vhost,mod_rest,<<"localhost">>} in context child_terminated
Configration settings used in yml :
mod_rest: []
-
port: 5285
module: ejabberd_http
request_handlers:
"/rest": mod_rest
I think it means you should
I think it means you should also start the module from the modules section as well.
You configured ejabberd to
You configured ejabberd to provide an XMPP server for the host name "example.com" right? Something like
And later you make HTTP requests providing in the HTTP client as host "localhost". Or at least that's what ejabberd HTTP server understands.
As mod_rest is not serving a vhost called "localhost", it doesn't know which options to apply to that request. Solutions: either provide the proper host in the HTTP request, or add that vhost to ejabberd.yml list of served hostnames.
I am doing the same, whenever
I am doing the same, whenever I excute this command on terminal $> curl -v localhost:5285/rest :
display below the crash log.
crash.log
2015-06-24 18:57:01.424 [info] <0.444.0>@ejabberd_listener:accept:304 (#Port<0.3966>) Accepted connection 127.0.0.1:55108 -> 127.0.0.1:5285
2015-06-24 18:57:01.425 [info] <0.568.0>@ejabberd_http:init:155 started: {gen_tcp,#Port<0.3966>}
2015-06-24 18:57:01.432 [error] <0.568.0> CRASH REPORT Process <0.568.0> with 0 neighbours crashed with reason: call to undefined function p1_logger:debug_msg(mod_rest, 60, "Got request to ~p: ~p", [[],{request,'GET',[<<"rest">>],[{nokey,<<>>}],{<<>>,<<>>},undefined,<<"en">>,<<>>,{{127,0,0,1},...},...}])
2015-06-24 18:57:01.433 [error] <0.326.0> Supervisor ejabberd_http_sup had child undefined started with {ejabberd_http,start_link,undefined} at <0.568.0> exit with reason undef in context child_terminated
Please sgguest solution
Your build / install is
Your build / install is incorrect, as shown by undefined module errors.
Ok, so the previous problem
Ok, so the previous problem was caused by what I said. And now you are facing a different one: apparently mod_rest got compiled with some option (the default one probably) to use p1_logger, which apparently is not included with your ejabberd installation.
I can't provide some specific solution, so I recommend you:
ejabberd 15.06 is almost ready to be released. When available, install it, then install mod_rest using the recommended method:
ejabberdctl modules_update_specs
ejabberdctl module_install mod_rest
And let's hope that solves the problem.
Now the it give error
Now the it give error message Try POSTing a stanza. my php code is below:-
<?php
$request = "<message from='mayank@mydomian.org'
to='manoj@mydomian.org'
type='chat'>
<body>this message is send by php script </body>
</message>";
$params="data=$request&host=mydomain.org&ip=192.168.1.11&method=POST";
$stream = fopen('php://memory','r+');
fwrite($stream, $params);
rewind($stream);
$url = "http://mydomain.org:5285/rest";
$fp = fopen($url, false, stream_get_contents($stream));
echo $response = stream_get_contents($fp);
?>
Please suggest me a solution!