processone / ejabberd-contrib

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

ejabberd_http_auth crash #274

Closed hksinsinwar closed 5 years ago

hksinsinwar commented 5 years ago

Ejabberd server : 19.3 I am seeing this error in log, related issues are already reported, but none of the solutions worked for me. Please give a some insights or help in this as I am not a ERLang specialist

2019-05-22 10:59:18 =ERROR REPORT====
** Generic server <0.1394.0> terminating
** Last message in was {'$gen_event',{xmlstreamelement,{xmlel,<<"auth">>,[{<<"xmlns">>,<<"urn:ietf:params:xml:ns:xmpp-sasl">>},{<<"mechanism">>,<<"PLAIN">>}],[{xmlcdata,<<"c2hpcHJhX3RyaXBhdGhpQHVuaWZ5ZWQuY29tAHNoaXByYV90cmlwYXRoaQBkY2M2OWQ0Mi05MmFhLTM0MjktOTUxZi1kNDMwZTA3YWVlNDM=">>}]}}}
** When Server state == #{resource => <<>>,mgmt_state => inactive,user => <<>>,tls_options => [compression_none],mgmt_stanzas_req => 0,server => <<"unifyed.com">>,mgmt_ack_timeout => 60000,stream_id => <<"15028015113414822089">>,socket => {socket_state,ejabberd_http_ws,{http_ws,<0.1393.0>,{{0,0,0,0,0,65535,44048,2750},58283}},262144,undefined,none,none},stream_direction => in,stream_compressed => false,mgmt_max_queue => 5000,stream_restarted => false,stream_authenticated => false,shaper => c2s_shaper,stream_version => {1,0},mgmt_resend => if_offline,access => c2s,stream_encrypted => false,mgmt_queue_type => ram,socket_monitor => #Ref<0.4289807260.2389966849.222209>,lserver => <<"unifyed.com">>,pres_a => {0,nil},mgmt_stanzas_in => 0,mgmt_stanzas_out => 0,xmlns => <<"jabber:client">>,owner => <0.1394.0>,tls_verify => false,csi_queue => {0,#{}},stream_header_sent => true,mod => ejabberd_c2s,mgmt_max_timeout => 300,ip => {{0,0,0,0,0,65535,44048,2750},58283},stream_state => wait_for_sasl_request,zlib => false,tls_enabled => false,csi_state => active,codec_options => [ignore_els],stream_timeout => {30000,-576460254921},mgmt_timeout => 300,tls_required => false,lang => <<"en">>}
** Reason for termination ==
** {{badmatch,{error,econnrefused}},[{ejabberd_auth_http,make_req,5,[{file,"/root/ejabberd-src/ejabberd-contrib-master/sources/ejabberd_auth_http/src/ejabberd_auth_http.erl"},{line,226}]},{ejabberd_auth_http,check_password,4,[{file,"/root/ejabberd-src/ejabberd-contrib-master/sources/ejabberd_auth_http/src/ejabberd_auth_http.erl"},{line,83}]},{ejabberd_auth,'-db_check_password/7-fun-0-',5,[{file,"src/ejabberd_auth.erl"},{line,644}]},{ets_cache,update,5,[{file,"src/ets_cache.erl"},{line,184}]},{ejabberd_auth,db_check_password,7,[{file,"src/ejabberd_auth.erl"},{line,641}]},{ejabberd_auth,'-check_password_with_authmodule/6-fun-0-',8,[{file,"src/ejabberd_auth.erl"},{line,240}]},{lists,foldl,3,[{file,"lists.erl"},{line,1263}]},{xmpp_sasl_plain,mech_step,2,[{file,"src/xmpp_sasl_plain.erl"},{line,42}]}]}
2019-05-22 10:59:18 =CRASH REPORT====
  crasher:
    initial call: xmpp_stream_in:init/1
    pid: <0.1394.0>
    registered_name: []
    exception exit: {{{badmatch,{error,econnrefused}},[{ejabberd_auth_http,make_req,5,[{file,"/root/ejabberd-src/ejabberd-contrib-master/sources/ejabberd_auth_http/src/ejabberd_auth_http.erl"},{line,226}]},{ejabberd_auth_http,check_password,4,[{file,"/root/ejabberd-src/ejabberd-contrib-master/sources/ejabberd_auth_http/src/ejabberd_auth_http.erl"},{line,83}]},{ejabberd_auth,'-db_check_password/7-fun-0-',5,[{file,"src/ejabberd_auth.erl"},{line,644}]},{ets_cache,update,5,[{file,"src/ets_cache.erl"},{line,184}]},{ejabberd_auth,db_check_password,7,[{file,"src/ejabberd_auth.erl"},{line,641}]},{ejabberd_auth,'-check_password_with_authmodule/6-fun-0-',8,[{file,"src/ejabberd_auth.erl"},{line,240}]},{lists,foldl,3,[{file,"lists.erl"},{line,1263}]},{xmpp_sasl_plain,mech_step,2,[{file,"src/xmpp_sasl_plain.erl"},{line,42}]}]},[{p1_server,terminate,7,[{file,"src/p1_server.erl"},{line,878}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,249}]}]}
    ancestors: [<0.1393.0>,<0.1392.0>,ejabberd_http_sup,ejabberd_sup,<0.107.0>]
    message_queue_len: 2
    messages: [{tcp_closed,{http_ws,<0.1393.0>,{{0,0,0,0,0,65535,44048,2750},58283}}},{'DOWN',#Ref<0.4289807260.2389966849.222209>,process,<0.1393.0>,normal}]
    links: []
    dictionary: [{rand_seed,{#{bits => 58,jump => #Fun<rand.8.10897371>,next => #Fun<rand.5.10897371>,type => exrop,uniform => #Fun<rand.6.10897371>,uniform_n => #Fun<rand.7.10897371>,weak_low_bits => 1},[138696308966058638|118291534276181075]}},{'$internal_queue_len',0},{already_terminated,true}]
    trap_exit: false
    status: running
    heap_size: 6772
    stack_size: 27
    reductions: 38560
  neighbours:
prefiks commented 5 years ago

{error,econnrefused} means that ejabberd was not able to connect to http server that should handle http auth request, possibly connection blocked by firewall or wrong url in that auth_http configuration?

hksinsinwar commented 5 years ago

Hi @prefiks Thanks for your response. Can you help me out how can i get more information, like what is the auth server url and actual server url ejabberd is using, I am able to connect using CURL and postman curl -XGET http://127.0.0.1:8093/check_password

My configuration is

auth_method: http
auth_opts:
  host: "http://127.0.0.1:8093"
  connection_pool_size: 10
  connection_opts: []
  basic_auth: ""
  path_prefix: "/"
hksinsinwar commented 5 years ago

I added extra information in debug and findout that ejabberd_http_mod is trying to connect host http://localhost:12000 not the one i configured in auth_opts to http://localhost:8093

Can you help me why it is not picking the provided host for authentication ?

prefiks commented 5 years ago

Could you check if restarting ejabberd or executing 'ejabberdctl reload_config' fixes that? Possibly you changed your config after ejabberd already loaded it? Are both of those options at start of a line, there is no spaces before them?

hksinsinwar commented 5 years ago

Hi @prefiks Thanks for your kind support. Actually issue was with config file location. Ejabberd CONTRIB_MODULES_CONF_DIR variable, Upon installation ejabberd is not moving the configuration file from module to <>/conf/<>.yml file will be here.

Now it is picking the configuration, Thanks again 👍