[ejabberd] Exmpp bot with gen_server connect_TCP problem

CGS cgsmcmlxxv at gmail.com
Wed Nov 2 14:55:33 MSK 2011


An Ejabberd module is a part of the server-side XMPP. EXMPP is the 
client-side XMPP. What you are trying is to embed client-side into 
server-side which is meaningless because you try to connect to the 
server from within. For handling the packets, use the server handlers. 
For sending/receiving packets to/for an user, use client-side XMPP.

Now, depending what you need, there are some options from which I can 
guess few which may help you:
1. Server-application communication: see external services, for example.
2. User packet redirection: see Ejabberd handlers.
3. Server-server communication: see s2s module, for example.
But, since I have no knowledge about what you need, there may be other 
options which fit better your project.

Cheers,
CGS



On 11/02/2011 11:36 AM, Alexander Kuleshov wrote:
>
>
> 2011/11/2 Alexander Kuleshov <kuleshovmail at gmail.com 
> <mailto:kuleshovmail at gmail.com>>
>
>     Hello,
>
>     I try to run jabber bot in ejabberd, written with exmpp.
>
>     My bot is usual gen_server remade from example:
>     https://github.com/onlyshk/exmpp/blob/master/examples/echo_client.erl
>
>     If i run it from terminal it's ok i see online bot in admin page.
>     But if i try to run it with my ejabberd module, inside in it, i
>     get crash report:
>
>     =ERROR REPORT==== 2-Nov-2011::16:30:25 ===
>     ** State machine <0.416.0> terminating
>     ** Last event in was tcp_closed (for all states)
>     ** When State == stream_opened
>     ** Data == {state,digest,
>     {{jid,<<"mybot at localhost/exmpp#1320251360207273">>,
>     <<"mybot">>,<<"localhost">>,
>     <<"exmpp#1320251360207273">>},
>     "password"},
>     {0,0},
>     false,false,false,
>     [{compression,enabled},{starttls,enabled}],
>     "localhost","localhost",<0.415.0>,exmpp_socket,
>     {gen_tcp,#Port<0.5947>},
>     {xml_stream,
>     {gen_fsm,<0.416.0>},
>     {xml_parser,
>     [{max_size,infinity},
>     {root_depth,1},
>     {names_as_atom,true},
>     {emit_endtag,true},
>     {check_nss,xmpp},
>     {check_elems,xmpp},
>     {check_attrs,xmpp}],
>     #Port<0.5840>},
>     new,false,undefined},
>     "3244568556",undefined,<0.428.0>,undefined,undefined}
>     ** Reason for termination =
>     ** tcp_closed
>
>     =CRASH REPORT==== 2-Nov-2011::16:30:25 ===
>     crasher:
>     initial call: exmpp_session:init/1
>     pid: <0.416.0>
>     registered_name: []
>     exception exit: tcp_closed
>     in function gen_fsm:terminate/7
>     ancestors: [mybot,ejabberd_sup,<0.40.0>]
>     messages: []
>     links: []
>     dictionary: [{random_seed,{1320,8904,23723}}]
>     trap_exit: false
>     status: running
>     heap_size: 1597
>     stack_size: 24
>     reductions: 1162
>     neighbours:
>     How can i run it with ejabberd module?
>
>     Thank you.
>
>
> And also i got:
>
> =CRASH REPORT==== 2-Nov-2011::16:29:25 ===
> crasher:
> initial call: xmpp_talker:init/1
> pid: <0.415.0>
> registered_name: []
> exception exit: {timeout,{gen_fsm,sync_send_event,
> [<0.416.0>,
> {connect_socket,"localhost",5222,[]},
> 5000]}}
> in function gen_server:init_it/6
> ancestors: [ejabberd_sup,<0.40.0>]
> messages: []
> links: [<0.245.0>]
> dictionary: []
> trap_exit: false
> status: running
> heap_size: 610
> stack_size: 24
> reductions: 320
> neighbours:
>
>
> _______________________________________________
> ejabberd mailing list
> ejabberd at jabber.ru
> http://lists.jabber.ru/mailman/listinfo/ejabberd

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.jabber.ru/pipermail/ejabberd/attachments/20111102/60c3bfe5/attachment.html>


More information about the ejabberd mailing list