What is Megaphone?

What is Megaphone?
The Megaphone project is about enhancing open source chat software. Specifically, the goal is to allow ejabberd to support 1,000,000 simultaneous users. See The Plan page for more details on how I plan to solve this problem. See the About this Blog page for more details on why I created this blog.

Thursday, December 15, 2011

Don't Cross the Streams!

Previously on megaphone-ejabber: I was trying to get Pidgin to work with NXB.
  • I had added the stream:features stanza to the initial response, but this did not seem to change anything.
  • I noticed that NXB was using chunked encoding and tried turning that off, which seemed to improve things.
  • Pidgin was reporting an "invalid response" after that.
I hooked up wireshark to use instead of my erlang program and then noticed the following:
  • Pidgin was sending a terminate request for the connection.
  • The last stanza sent before the terminate from Pidgin was the following:
<body 
    xmlns="http://jabber.org/protocol/httpbind" 
    stream="80637d72-5b13-42a5-af37-7602fba5d1f6">
        <success 
            xmlns="jabber:client" 
            xmlns:stream="http://etherx.jabber.org/streams" 
            version="1.0"/>
</body>

Looking through the documentation for XMPP this appears to be part of a SASL conversation - something that is used to set up a secure connection.  The previous request to NXB looked reasonable enough:

<body 
    rid='1281657012969807' 
    sid='4415519b-d025-4330-8517-6c20a57b7990' 
    to='ubuntu2' 
    xml:lang='en' 
    xmlns='http://jabber.org/protocol/httpbind' 
    xmlns:xmpp='urn:xmpp:xbosh'>
</body>

According to the spec, this is a request to open a new stream - the <success> stanza did not belong there at all.  Looking back through the log I found the following:

<body 
    rid='1281657012969806' 
    sid='4415519b-d025-4330-8517-6c20a57b7990' 
    to='ubuntu2' 
    xml:lang='en' 
    xmlns='http://jabber.org/protocol/httpbind' 
    xmlns:xmpp='urn:xmpp:xbosh'>
        <auth 
            xmlns='urn:ietf:params:xml:ns:xmpp-sasl' 
            mechanism='PLAIN' 
            xmlns:ga='http://www.google.com/talk/protocol/auth' 
            ga:client-uses-full-bind-result='true'>AHVzZXIyAHRlc3QkZWphYmJlcmQ=</auth>
</body>

This appears to be part of the XMPP conversation to authorize a connection.  

At this point, it appeared to me that the connections were getting out of sync - my modification to pause until the <stream:features> stanza was received from the server could be having the unintended side-effect of messing up the SASL conversation.  Working from the premise that the NXB's use of chunked encoding was the cause of the previous problems instead of the <stream:features> stanza, I tried removing the pause.  

Now instead of "invalid response" Pidgin started complaining that the resource was unavailable.

Progress, I guess.

No comments:

Post a Comment