processone / ejabberd-contrib

Growing and curated ejabberd contributions repository - PR or ask to join !
http://ejabberd.im
248 stars 137 forks source link

after installing ejabberd_auth_http crash on ejabberd 18.09 #264

Closed damirci closed 5 years ago

damirci commented 5 years ago

I have installed ejabberd_auth_http with this configs:


auth_method: http
auth_opts:
  host: "http://192.168.10.100:81"
  connection_pool_size: 10
  connection_opts: []
  basic_auth: ""
  path_prefix: "/"
auth_use_cache: false
auth_password_format: plain

and I coppied beam files from C:\ProgramData\ejabberd\.ejabberd-modules\ejabberd_auth_http\ebin to C:\Program Files\ejabberd\lib\ejabberd-18.09\ebin.

when I want to authenticate to admin panel this logs generates is log files:

crash.log 2018-12-05 12:13:26 =CRASH REPORT==== crasher: initial call: ejabberd_http:init/2 pid: <0.523.0> registered_name: [] exception error: {{badmatch,{error,econnrefused}},[{ejabberd_auth_http,make_req,5,[{file,"c:/ProgramData/ejabberd/.ejabberd-modules/sources/ejabberd-contrib/ejabberd_auth_http/src/ejabberd_auth_http.erl"},{line,225}]},{ejabberd_auth_http,check_password,4,[{file,"c:/ProgramData/ejabberd/.ejabberd-modules/sources/ejabberd-contrib/ejabberd_auth_http/src/ejabberd_auth_http.erl"},{line,83}]},{ejabberd_auth,'-check_password_with_authmodule/6-fun-0-',8,[{file,"src/ejabberd_auth.erl"},{line,239}]},{lists,foldl,3,[{file,"lists.erl"},{line,1263}]},{ejabberd_auth,check_password,6,[{file,"src/ejabberd_auth.erl"},{line,215}]},{ejabberd_web_admin,get_auth_account,5,[{file,"src/ejabberd_web_admin.erl"},{line,262}]},{ejabberd_web_admin,process,2,[{file,"src/ejabberd_web_admin.erl"},{line,216}]},{ejabberd_http,process,2,[{file,"src/ejabberd_http.erl"},{line,401}]}]} ancestors: [ejabberd_http_sup,ejabberd_sup,<0.80.0>] message_queue_len: 0 messages: [] links: [<0.509.0>,#Port<0.34>] dictionary: [] trap_exit: false status: running heap_size: 4185 stack_size: 27 reductions: 14515 neighbours: 2018-12-05 12:13:26 =SUPERVISOR REPORT==== Supervisor: {local,ejabberd_http_sup} Context: child_terminated Reason: {{badmatch,{error,econnrefused}},[{ejabberd_auth_http,make_req,5,[{file,"c:/ProgramData/ejabberd/.ejabberd-modules/sources/ejabberd-contrib/ejabberd_auth_http/src/ejabberd_auth_http.erl"},{line,225}]},{ejabberd_auth_http,check_password,4,[{file,"c:/ProgramData/ejabberd/.ejabberd-modules/sources/ejabberd-contrib/ejabberd_auth_http/src/ejabberd_auth_http.erl"},{line,83}]},{ejabberd_auth,'-check_password_with_authmodule/6-fun-0-',8,[{file,"src/ejabberd_auth.erl"},{line,239}]},{lists,foldl,3,[{file,"lists.erl"},{line,1263}]},{ejabberd_auth,check_password,6,[{file,"src/ejabberd_auth.erl"},{line,215}]},{ejabberd_web_admin,get_auth_account,5,[{file,"src/ejabberd_web_admin.erl"},{line,262}]},{ejabberd_web_admin,process,2,[{file,"src/ejabberd_web_admin.erl"},{line,216}]},{ejabberd_http,process,2,[{file,"src/ejabberd_http.erl"},{line,401}]}]} Offender: [{pid,<0.523.0>},{id,undefined},{mfargs,{ejabberd_http,start_link,undefined}},{restart_type,temporary},{shutdown,1000},{child_type,worker}]

error.log

2018-12-05 12:13:26.833 [error] <0.523.0>@ejabberd_auth_http:make_req:225 CRASH REPORT Process <0.523.0> with 0 neighbours crashed with reason: no match of right hand value {error,econnrefused} in ejabberd_auth_http:make_req/5 line 225 2018-12-05 12:13:26.833 [error] <0.509.0>@ejabberd_auth_http:make_req:225 Supervisor ejabberd_http_sup had child undefined started with {ejabberd_http,start_link,undefined} at <0.523.0> exit with reason no match of right hand value {error,econnrefused} in ejabberd_auth_http:make_req/5 line 225 in context child_terminated

ejabberd.log

2018-12-05 12:13:25.802 [info] <0.376.0>@ejabberd_listener:accept:221 (<0.523.0>) Accepted connection ::1:52341 -> ::1:5280 2018-12-05 12:13:26.833 [error] <0.523.0>@ejabberd_auth_http:make_req:225 CRASH REPORT Process <0.523.0> with 0 neighbours crashed with reason: no match of right hand value {error,econnrefused} in ejabberd_auth_http:make_req/5 line 225 2018-12-05 12:13:26.833 [error] <0.509.0>@ejabberd_auth_http:make_req:225 Supervisor ejabberd_http_sup had child undefined started with {ejabberd_http,start_link,undefined} at <0.523.0> exit with reason no match of right hand value {error,econnrefused} in ejabberd_auth_http:make_req/5 line 225 in context child_terminated

badlop commented 5 years ago

exception error: {{badmatch,{error,econnrefused}},[{ejabberd_auth_http,make_req,5,

This line says that, when making a HTTP request, ejabberd got the connection refused.

In case you need help debugging the problem: If you set loglevel to 5 in ejabberd.yml, you should get a log line indicating the Path that is to be requested, just before the crash.

damirci commented 5 years ago

just logs in ejabberd.log changed like this:

2018-12-05 15:58:19.623 [info] <0.378.0>@ejabberd_listener:accept:221 (<0.525.0>) Accepted connection ::1:51480 -> ::1:5280 2018-12-05 15:58:19.623 [debug] <0.525.0>@ejabberd_http:init:149 S: [{[<<"ws">>],ejabberd_http_ws},{[<<"bosh">>],mod_bosh},{[<<"oauth">>],ejabberd_oauth},{[<<"api">>],mod_http_api},{[<<"admin">>],ejabberd_web_admin}] 2018-12-05 15:58:19.623 [debug] <0.525.0>@ejabberd_http:process_header:304 (#Port<0.30>) http query: 'GET' <<"/admin/">> 2018-12-05 15:58:19.623 [debug] <0.525.0>@ejabberd_http:process:391 [<<"admin">>] matches [<<"admin">>] 2018-12-05 15:58:19.623 [debug] <0.525.0>@ejabberd_auth_http:make_req:224 Making request 'check_password' for user admin@test.com... 2018-12-05 15:58:20.654 [error] <0.525.0>@ejabberd_auth_http:make_req:225 CRASH REPORT Process <0.525.0> with 0 neighbours crashed with reason: no match of right hand value {error,econnrefused} in ejabberd_auth_http:make_req/5 line 225 2018-12-05 15:58:20.654 [error] <0.511.0>@ejabberd_auth_http:make_req:225 Supervisor ejabberd_http_sup had child undefined started with {ejabberd_http,start_link,undefined} at <0.525.0> exit with reason no match of right hand value {error,econnrefused} in ejabberd_auth_http:make_req/5 line 225 in context child_terminated 2018-12-05 15:58:20.654 [debug] <0.526.0>@ejabberd_http:init:149 S: [{[<<"ws">>],ejabberd_http_ws},{[<<"bosh">>],mod_bosh},{[<<"oauth">>],ejabberd_oauth},{[<<"api">>],mod_http_api},{[<<"admin">>],ejabberd_web_admin}]

badlop commented 5 years ago

I get that same error message when I attempt to connect to an IP address and port where nothing is listening. However, if I set the IP and port of an accessible web server, then the connection is established, even if that server has nothing to do with me.

For example, configure the module to use www.google.com (which obviously will fail the auth, but at least accepts the connection):

auth_opts:
  host: "http://216.58.211.228:80"

16:16:18.708 [info] (<0.505.0>) Accepted connection ::ffff:127.0.0.1:44605 -> ::ffff:127.0.0.1:5222
16:16:18.848 [warning] (tcp|<0.505.0>) Failed c2s PLAIN authentication for
 user2@localhost from ::ffff:127.0.0.1: Invalid username or password
abdularis commented 5 years ago

It maybe late but FYI, in the latest version, there is ~/.ejabberd_modules/ejabberd_auth_http/conf/ejabberd_auth_http.yml file which will somehow override the configuration for _ejabberd_authhttp in your ejabberd.yml, you can modify ejabberd_auth_http.ymland don't need to copy _ejabberd_authhttp.beam into your ejabberd ebin installation dir.