jaxl / JAXL

Asynchronous, non-blocking I/O, event based PHP library for writing custom TCP/IP client and server implementations. From it's previous versions, library inherits a full blown stable support for XMPP protocol stack. In v3.0, support for HTTP protocol stack was also added.
http://jaxl.readthedocs.org/
Other
379 stars 121 forks source link

BOSH Problem #24

Open DavidusEdwardus opened 11 years ago

DavidusEdwardus commented 11 years ago

Can't seem to connect via BOSH , the error returned by JAXL is :

jaxl:219 - 2012-12-06 13:32:07 - strict mode enabled, adding exception handlers. Set 'strict'=>TRUE inside JAXL config to disable this jaxl_exception:66 - 2012-12-06 13:32:07 - error handler called with 8, Undefined index: priv_dir, /home/david/Downloads/JAXL-3.x/jaxl.php, 146 jaxl:166 - 2012-12-06 13:32:07 - created pid file /home/david/Downloads/JAXL-3.x/.jaxl/run/jaxl_31179.pid xmpp_stream:112 - 2012-12-06 13:32:07 - got invalid return value from state handler 'wait_for_bind_response', sending end stream... xmpp_stream:115 - 2012-12-06 13:32:07 - state handler 'logged_out' returned N;, kindly report this to developers ^Cjaxl_exception:48 - 2012-12-06 13:32:08 - got jaxl exception construct with Undefined offset: 0, 8, /home/david/Downloads/JAXL-3.x/jaxl.php, 769

I have tested this with node-xmmp-bosh , and pubjab, both return the same result.

If needed , I can give you the full debugging output from node-xmpp-bosh.

DavidusEdwardus commented 11 years ago

This may or may not be a bug in JAXL, but here are my findings.

Using SASL PLAIN , rfc4616 defines the auth string as

authzid[null]authcid[null]passwd

The format of authzid supposedly depends on the XMPP SASL profile, but I wasnt able to dig much up on it. Both authcid and passwd are form free.

JAXL is presenting the auth string for PLAIN as :

JID[null]passwd

Which my XMPP server barfed on.

Other libs, notably strophe, send the auth string as

JID[null]username[null]passwd

I'm not really sure where the fault lies here, as JAXL is sending the JID as the authcid, which has no set format. Other libs I have looked at seem to agree with Strophe in sending all three tokens as per rfc4616, but it also seems acceptable to send :

username[null]passwd

missing out the authzid entirely. In this case the rfc states :

When no authorization identity is provided, the server derives an authorization identity from the prepared representation of the provided authentication identity string. This ensures that the derivation of different representations of the authentication identity produces the same authorization identity.

This seems to me that all three tokens should be presented, where the authzid is not provided, it it derived from the authcid, but that's just my interpretation.

As a quick fix in jaxl.php , changing line 646 to :

$this-]send_auth_pkt($mech, @$this-]jid ? $this-]jid-]node : null, @$this-]pass);

solved the issue for me, though as I say, I'm not sure whats technically correct as it seems a bit of a gray area !

wishmedia commented 11 years ago

I know this is a little old - but I just went through the same issue. I kept receiving a even tho I was positive the password was right.

After some searching, I noticed the encoded password being sent was different than what was being sent by Strophe.

This led me to jaxl/xmpp/xmpp_stream.php where the "get_auth_pkt" function lives. I modified line #160 for the "PLAIN" mechanism to: base64_encode( $user . chr(0) . substr($user,0,strpos($user,'@')) . chr(0) . $pass )

Then I was able to log in fine.

richardaum commented 10 years ago

@wishmedia THANK YOU A LOT, DUDE! I spend A LOT OF HOURS trying to solving this problem. I am using your solution and it is working as well...

Reading the logs I saw that something was wrong with pwd encrypt. Thanks again!!

richardaum commented 10 years ago

Both solutions worked for me!