1

I have a very simple client program:

class EchoClient(Int32StringReceiver):

    def connectionMade(self):
        print 'connection made.'
        str = "<request><commands><dbtest /></commands></request>"
        self.sendString(str)
        print 'message sent'

    def stringReceived(self, line):
        print "receive:", line
        self.transport.loseConnection()

class EchoClientFactory(ClientFactory):

    def buildProtocol(self, addr):
        return EchoClient()

    def clientConnectionFailed(self, connector, reason):
        print 'connection failed:', reason.getErrorMessage()
        reactor.stop()

    def clientConnectionLost(self, connector, reason):
        print 'connection lost:', reason.getErrorMessage()
        reactor.stop()

def main():
    factory = EchoClientFactory()
    reactor.connectTCP('localhost', 3604, factory)
    reactor.run()

I connect to a Java service implemented in Apache CXF (and some proprietary company code).

It connects fine, sends the message, the service receives it and produces a response.

Sadly, this client does not wait for the server to produce its message, but disconnects right after the message is sent. So the output I get from the client is:

connection made. 
message sent 
connection lost: Connection was closed cleanly.

And of course the Java service throws an exception complaining about the connection being already closed.

What am I missing here?

EDIT: adding this line shows that the message is received, as it prints it correctly:

def dataReceived(self, data):
    print(data)
    self.transport.loseConnection()

So the real problem is that the stringReceived() function is not called. Maybe I have the wrong signature for this function?

egbokul
  • 3,944
  • 7
  • 36
  • 54

1 Answers1

0

I'm onto something here:

def lengthLimitExceeded(self, length):
    print('length limit exceeded: {}'.format(length))

prints:

length limit exceeded: 2147483793
length limit exceeded: 2147483793

which is 0x80000091, so it seems that our propietary API is implementing the NString protocol in a strange way (maybe uses the MSB for something else).

egbokul
  • 3,944
  • 7
  • 36
  • 54