[ejabberd] Working with exmpp as a server

Shaun Kruger shaun.kruger at gmail.com
Sun Jul 17 02:26:26 MSD 2011


I decided to play with exmpp for a project of mine.  I'm trying to
parse the opening of an XMPP stream.  I'm not sure what to do about
this error.   Here is essentially what my code is doing:

Parser = exmpp_xml:start_parser([{root_depth,1},{check_nss,xmpp},{check_elems,xmpp}]),
OpenStream = exmpp_xml:parse(Parser,XMLBinaryData),
....

I have two test values for XMLBinaryData.  One works and the other
doesn't.  The error reports are my own debugging statements from my
application after the call to exmpp_xml:parse() succeeds or fails.
I'm sure I have a setting wrong in my start_parser(), but I can't tell
what I am doing wrong from reading about xmlparseroption() and
start_parser() in the manual.

This does not work:
<<"<?xml version='1.0' ?><stream:stream to='example.com'
xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams'
version='1.0'>">>

=ERROR REPORT==== 16-Jul-2011::16:08:18 ===
XMPP Error: {xml_parser,parsing,parsing_failed,
                        {17,"XML or text declaration not at start of entity"}}


This does:
<<"<stream:stream to='example.com' xmlns='jabber:client'
xmlns:stream='http://etherx.jabber.org/streams' version='1.0'>\r\n">>

=ERROR REPORT==== 16-Jul-2011::16:10:46 ===
Got open stream: [{xmlel,'http://etherx.jabber.org/streams',
                         [{'jabber:client',none},
                          {'http://etherx.jabber.org/streams',"stream"}],
                         stream,
                         [{xmlattr,undefined,<<"to">>,<<"example.com">>},
                          {xmlattr,undefined,<<"version">>,<<"1.0">>}],
                         undefined},
                  {xmlcdata,<<"\n">>}]


I'm not sure what I am doing wrong.  Any suggestions would be appreciated.

Shaun


More information about the ejabberd mailing list