thrift-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Knick, Scott E CTR USARMY RCERT-EUR (US)" <>
Subject Error with TSSLServerSocket (Python 2.6) (UNCLASSIFIED)
Date Mon, 17 Jun 2013 12:28:06 GMT
Classification: UNCLASSIFIED
Caveats: NONE


I'm having some issues trying to use the TSSLServerSocket class in the Thrift Python APIs
(I'm using Thrift 0.9.0 with Python 2.6). I have previously successfully used Thrift for a
Perl/PHP client and C++ server, though this is the first time I have tried to use SSL with
Thrift and the first time I've tried to use Python for my server.

Basically, I'm experiencing an error whenever I try to run the following server and then connect
to it with a Python client. (Note that I've verified that I can connect just fine when I use
a TServerSocket instead of TSocket.)

    import sys
    import thrift.transport.TSSLSocket
    import thrift.transport.TTransport
    import thrift.protocol.TBinaryProtocol
    import thrift.server.TServer
    import My.Class
    class MyHandler:
        def say(self, greeting):
            print greeting
    handler = MyHandler()
    processor = My.Class.Processor(handler)
    transport = thrift.transport.TSSLSocket.TSSLServerSocket("localhost", 9090, "server.crt")
    tfactory = thrift.transport.TTransport.TBufferedTransportFactory()
    pfactory = thrift.protocol.TBinaryProtocol.TBinaryProtocolFactory()
    server = thrift.server.TServer.TSimpleServer(processor, transport, tfactory, pfactory)
    print 'Starting the server...'
    print 'done.'

Here is the client code:

    import sys
    import thrift.Thrift
    import thrift.transport.TSSLSocket
    import thrift.transport.TTransport
    import thrift.protocol.TBinaryProtocol
    import My.Class
        transport = thrift.transport.TSSLSocket.TSSLSocket("localhost", 9090, False)
        transport = thrift.transport.TTransport.TBufferedTransport(transport)
        protocol = thrift.protocol.TBinaryProtocol.TBinaryProtocol(transport)
        client = My.Class.Client(protocol)
        client.say("Hi, this is Scott!")
    except thrift.Thrift.TException, tx:
        print '%s' % (tx.message)

Whenever I run the server and then run the client script, I get the following error:

    Starting the server...
    ERROR:root:'NoneType' object has no attribute 'read'
    Traceback (most recent call last):
      File "/usr/lib64/python2.6/site-packages/thrift/server/", line 84, in serve
        self.processor.process(iprot, oprot)
      File "/home/knicksc/generated/My/", line 72, in process
        (name, type, seqid) = iprot.readMessageBegin()
      File "/usr/lib64/python2.6/site-packages/thrift/protocol/", line 126,
in readMessageBegin
        sz = self.readI32()
      File "/usr/lib64/python2.6/site-packages/thrift/protocol/", line 206,
in readI32
        buff = self.trans.readAll(4)
      File "/usr/lib64/python2.6/site-packages/thrift/transport/", line 58, in
        chunk = - have)
      File "/usr/lib64/python2.6/site-packages/thrift/transport/", line 159,
in read
        self.__rbuf = StringIO(, self.__rbuf_size)))
    AttributeError: 'NoneType' object has no attribute 'read'
    Traceback (most recent call last):
      File "./", line 27, in <module>
      File "/usr/lib64/python2.6/site-packages/thrift/server/", line 90, in serve
      File "/usr/lib64/python2.6/site-packages/thrift/transport/", line 152,
in close
        return self.__trans.close()
    AttributeError: 'NoneType' object has no attribute 'close'

The client script shows the following error when this happens:

    Could not connect to localhost:9090

What am I missing? Any help is appreciated.

Scott Knick

Classification: UNCLASSIFIED
Caveats: NONE

View raw message