[Twisted-Python] Issues with creating switchboards with twisted.words.protocols.msn

Hermann Kaser hermann.kaser at gmail.com
Fri Jun 27 08:47:03 EDT 2008

Hello all,

I'm trying to write an MSN client but I've run into a problem: for
some reason when I create a Switchboard and try to invite someone it
sends the join command and the invitation command all together and the
MSN server doesn't answer any of them. Here's the relevant bits of the
code I have:

class Switchboard(msn.SwitchboardClient):
   def connectionMade(self):
        self.key = self.factory.key
        self.sessionID = self.factory.sessionID
        self.userHandle = self.factory.userHandle
        self.invite = self.factory.invite


        d = self.inviteUser(self.invite)

    def Invited(self, *args):
        print 'Running reply callback'

And this is the ngrep stream after the XFR request

# send transfer request
T -> [AP]
  CHG 6 NLN..XFR 7 SB..

# get transfer response
T -> [AP]
  XFR 7 SB CKI 712606054.15830117.2511186..

T -> [AP]
  CHG 6 NLN 0..

T -> [AP]
  ILN 6 NLN [redacted]@hotmail.com [redacted screenname] 1073741856..

T -> [AP]
  USR 1 [my email] 712606054.15830117.2511186..CAL 2 [email of who i
want to invite]..

If I try to do the same process with pidgin for example, the stream
looks exactly the same except the USR and CAL command are on separate
packets, and the server responds to the USR command before the client
sends the CAL command.

Can anyone help me out figuring this out? I know you can send more
than one command per packet, as seen in the first packet of the ngrep
stream I posted, so I don't see why it wouldn't work to send the USR
and CAL command together, but I suspect that not all commands may be
stuck together. I stuck a time.sleep(20) between the calling
msn.SwitchboardClient.connectionMade(self) and
self.inviteUser(self.invite) to see if it was a timing issue but what
happens is that the USR command gets buffered, and only when the
script tries to send the CAL command does the socket actually write it

Any help on this would be greatly appreciated, I've been digging
around the documentation and the code but I can't seem to figure out
why it's buffering the USR command and I don't know enough about the
MSN protocol to know which commands need a unique packet and which
ones can go with others.

Hermann Käser

More information about the Twisted-Python mailing list