esl / escalus

An XMPP client library in Erlang for conveniently testing XMPP servers
Apache License 2.0
129 stars 76 forks source link

How to use escalus component from elixir? #208

Open izigibran opened 5 years ago

izigibran commented 5 years ago

I am trying to connect escalus_component to mongooseim locally from elixir

I call this:

Interactive Elixir (1.6.4) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> conarg = [{:host, "localhost"}, {:password, "secret"},{:port, 8888},{:component,"mongooseim@localhost"}]
[
  host: "localhost",
  password: "secret",
  port: 8888,
  component: "mongooseim@localhost"
]
iex(2)> :escalus_component.start_link(:escalus_component, conarg, [])  
** (EXIT from #PID<0.282.0>) shell process exited with reason: an exception was raised:
    ** (FunctionClauseError) no function clause matching in :escalus_component.init/1
        /Users/gibranrodriguez/everdays/full-stack-react-phoenix/chat_app/deps/escalus/src/escalus_component.erl:103: :escalus_component.init([])
        /Users/gibranrodriguez/everdays/full-stack-react-phoenix/chat_app/deps/escalus/src/escalus_component.erl:109: :escalus_component.init/1
        (stdlib) gen_server.erl:365: :gen_server.init_it/2
        (stdlib) gen_server.erl:333: :gen_server.init_it/6
        (stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3

On Mongooseim node this happens:

2019-04-05 09:28:39.751 [debug] <0.425.0>@shaper_srv:handle_info:146 Deleted old shapers
2019-04-05 09:29:01.988 [info] <0.1040.0>@ejabberd_listener:accept:322 (#Port<0.18466>) Accepted connection {{127,0,0,1},62553} -> {{127,0,0,1},8888}
2019-04-05 09:29:01.988 [info] <0.1273.0>@ejabberd_service:init:158 ({socket_state,gen_tcp,#Port<0.18466>,<0.1272.0>}) External service connected
2019-04-05 09:29:02.009 [debug] <0.1272.0>@ejabberd_receiver:process_data:317 Received XML on stream = "<stream:stream to='mongooseim@localhost' xmlns='jabber:component:accept' xmlns:stream='http://etherx.jabber.org/streams'>"
2019-04-05 09:29:02.009 [debug] <0.1272.0>@shaper:update:60 Tokens: 49879 (+1025,-121), delay: 0 ms
2019-04-05 09:29:02.011 [debug] <0.1272.0>@ejabberd_receiver:process_data:317 Received XML on stream = "<handshake>86dd3e2badc5df02a1254b8545d206c8de9f81a5</handshake>"
2019-04-05 09:29:02.011 [debug] <0.1272.0>@shaper:update:60 Tokens: 49915 (+99,-63), delay: 0 ms
2019-04-05 09:29:02.012 [info] <0.1273.0>@ejabberd_service:terminate:389 terminated: normal

I guess I would like some help on an example how to connect escalus_component to mongooseim either from elixir or erlang