thrift-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Partridge, Lucas (GE Aviation)" <>
Subject Python clients can't connect to Thrift services running on "localhost" when no network connection is available
Date Tue, 29 Apr 2014 09:23:35 GMT
I'm not sure whether this is a bug or something different between Java and Python but I thought
other people might like to know this...

I had a Thrift 0.9.0 service running on my local machine in C#.  Java clients to this service
could connect using "localhost" even when no network connection was available but Python clients
failed with:

  File "C:\Python27\lib\site-packages\thrift-0.9.0-py2.7.egg\thrift\transport\",
line 99, in open
thrift.transport.TTransport.TTransportException: Could not connect to localhost:9092

The workaround is to use "" in Python clients. This is not necessary for Java clients.
Python test script:

from thrift.transport import TSocket

#host = "" # Works
host = "localhost" # Fails when no network connection is available
port = 9092

transp = TSocket.TSocket(host, port)
print 'Transport opened'
print 'Transport closed'

The Java equivalent runs fine, however:

TTransport transport = new TSocket("localhost", 9092);
try {
      ; // Works even if no network connection is available.


  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message