john pfeiffer
  • Home
  • Categories
  • Tags
  • Archives

xmpp connect no encryption

# 2013-07 johnpfeiffer connects but gets an error about encryption
# Connected.
# SEND: <stream:stream xmlns:stream='http://etherx.jabber.org/streams' xmlns='jabber:client' to='chat.hipchat.com'>
# RECV: <stream:stream xmlns:stream='http://etherx.jabber.org/streams' xmlns='jabber:client' from='chat.hipchat.com' # id='8419bffcc0a15f3d'><stream:features><starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'><required/></starttls></stream:features>
# SEND: <iq type='get' id='H_0'><query xmlns='jabber:iq:auth'><username>48340_325144</username></query></iq>
# RECV: <failure xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><encryption-required/></failure>
# control + c quits

import sys
from twisted.words.protocols.jabber import xmlstream, client, jid
from twisted.internet import reactor


def rawDataIn( buf ):
    print "RECV: %s" % unicode( buf , 'utf-8' ).encode( 'ascii' , 'replace' )

def rawDataOut( buf ):
    print "SEND: %s" % unicode( buf , 'utf-8' ).encode( 'ascii' , 'replace' )


def connected( xs ):
    print 'Connected.'
    xs.rawDataInFn = rawDataIn          # overrides the xmlstream functions to provide visibility into the stream
    xs.rawDataOutFn = rawDataOut


if __name__ == '__main__':
    if len( sys.argv ) != 3 :
        print "correct usage: python xmppclient.py fulljid@chat.hipchat.com/device password"
        sys.exit( 1 )

myJid = jid.JID( sys.argv[1] )
factory = client.basicClientFactory( myJid, sys.argv[2] )           # does not support TLS
factory.addBootstrap( xmlstream.STREAM_CONNECTED_EVENT , connected )    # when there's a connected event, use the connected function
reactor.connectTCP( 'chat.hipchat.com' ,5222, factory )      # connects to server:port using TCP, then uses callbacks registered with the factory
reactor.run()

  • « Packaging deb for ubuntu
  • xmpp connect XMPPClientFactory TLS »

Published

Jul 19, 2013

Category

python-twisted

~144 words

Tags

  • connect 6
  • encryption 3
  • no 6
  • python 180
  • twisted 20
  • xmpp 4