0

Why is the connection not getting established and resulting in thrift.transport.TTransport.TTransportException: TSocket read 0 bytes

I am trying to connect to hbase from python using thrift. I am working on a cloudera cdh5.14 cluster and the thrift server is running on the cluster. hbase version 1.2.0

It's been three weeks and I have already tried the following: Through the search I kind of know it has to do with thrift irrespective of python, happybase or hbase. It is a kerberized cluster and have made changes in protocol and transport mode as mentioned in the first link: I guess the solution should work if using happybase too. 1) Cloudera/CDH v6.1.x + Python HappyBase v1.1.0: TTransportException(type=4, message='TSocket read 0 bytes')

2) TSocket read 0 bytes - happybase version 0.8

3) thrift timeout for long run call: thrift.transport.TTransport.TTransportException: TSocket read 0 bytes

4) TSocket read 0 bytes accessing hive with python

5) TTransportException: TSocket read 0 bytes while accessing Hive via Python

6) python thrift error ```TSocket read 0 bytes```

7) Uncaught exception 'TTransportException' with message 'TSocket read 0 bytes'

8) TSocket read 0 bytes Apache Thrift MongoDB

from thrift.transport import TSocket
from thrift.protocol import TCompactProtocol
from thrift.transport.TTransport import TFramedTransport
from hbase import Hbase


(host, port) = ("cluster.hostname", 9090)
transport = TFramedTransport(TSocket.TSocket(host, port))
protocol = TCompactProtocol.TCompactProtocol(transport)
client = Hbase.Client(protocol)

transport.open()
print(client.getTableNames())

The snippet of error is kind of similar to most in the above links

Traceback (most recent call last):
  File "testing.py", line 14, in <module>
    print(client.getTableNames())
  File "/home/caston/final_attempt/gen-py/hbase/Hbase.py", line 786, in getTableNames
    return self.recv_getTableNames()
  File "/home/caston/final_attempt/gen-py/hbase/Hbase.py", line 796, in recv_getTableNames
    (fname, mtype, rseqid) = self._iprot.readMessageBegin()
  File "/usr/lib64/python2.7/site-packages/thrift/protocol/TCompactProtocol.py", line 310, in readMessageBegin
    proto_id = self.__readUByte()
  File "/usr/lib64/python2.7/site-packages/thrift/protocol/TCompactProtocol.py", line 289, in __readUByte
    result, = unpack('!B', self.trans.readAll(1))
  File "/usr/lib64/python2.7/site-packages/thrift/transport/TTransport.py", line 58, in readAll
    chunk = self.read(sz - have)
  File "/usr/lib64/python2.7/site-packages/thrift/transport/TTransport.py", line 276, in read
    self.readFrame()
  File "/usr/lib64/python2.7/site-packages/thrift/transport/TTransport.py", line 280, in readFrame
    buff = self.__trans.readAll(4)
  File "/usr/lib64/python2.7/site-packages/thrift/transport/TTransport.py", line 58, in readAll
    chunk = self.read(sz - have)
  File "/usr/lib64/python2.7/site-packages/thrift/transport/TSocket.py", line 120, in read
    message='TSocket read 0 bytes')
thrift.transport.TTransport.TTransportException: TSocket read 0 bytes

Any kind of help will be very much appreciated!

  • Possible duplicate of [python thrift error \`\`\`TSocket read 0 bytes\`\`\`](https://stackoverflow.com/questions/39371489/python-thrift-error-tsocket-read-0-bytes) – JensG Apr 03 '19 at 14:01
  • Thank you @JensG for that. I did try that out and it does work fine. The only problem in my case is I am trying to do this on a cloudera cluster. The HBase thrift server is already started by the cluster admin and `client.getTableNames()` results in the same error. The only difference here is there is no server file as mentioned in the link you commented with since I guess the thrift server is already running. I may be wrong though. Anxiously looking for a solution! – Caston Fernandes Apr 19 '19 at 02:38

0 Answers0