dropbox / PyHive

Python interface to Hive and Presto. 🐝
Other
1.67k stars 550 forks source link

thrift.transport.TTransport.TTransportException: TSocket read 0 bytes #202

Open pramodvspk opened 6 years ago

pramodvspk commented 6 years ago

Hi, I am using PyHive to access Kerberos authenticated Hive cluster.

from pyhive import hive
conn = hive.Connection(host='XXX', port=10001, auth='KERBEROS', database='XXX', kerberos_service_name='hive')

I get the error

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/ksripada/.local/lib/python2.7/site-packages/pyhive/hive.py", line 162, in __init__
    self._transport.open()
  File "/usr/local/anaconda4/lib/python2.7/site-packages/thrift_sasl/__init__.py", line 80, in open
    status, payload = self._recv_sasl_message()
  File "/usr/local/anaconda4/lib/python2.7/site-packages/thrift_sasl/__init__.py", line 101, in _recv_sasl_message
    payload = read_all_compat(self._trans, length)
  File "/usr/local/anaconda4/lib/python2.7/site-packages/thrift_sasl/six.py", line 31, in <lambda>
    read_all_compat = lambda trans, sz: trans.readAll(sz)
  File "/home/ksripada/.local/lib/python2.7/site-packages/thrift/transport/TTransport.py", line 60, in readAll
    chunk = self.read(sz - have)
  File "/home/ksripada/.local/lib/python2.7/site-packages/thrift/transport/TSocket.py", line 132, in read
    message='TSocket read 0 bytes')
thrift.transport.TTransport.TTransportException: TSocket read 0 bytes

PyHive Version: 0.5.1 thrift Version: 0.10.0 sasl Version: 0.2.1 thrift-sasl Version: 0.2.1

I have tried all possible approaches by following the issues on PyHive but still was getting the same error. Could any one please let me know if I am using the wrong version of Python modules.

pramodvspk commented 6 years ago

@jingw could you please help me with this issue. Thank you.

Sarnath commented 6 years ago

I had the same problem where the python program will simply fail with this error message immediately... So, thats not a timeout problem. It turned out that the hiveserver2 was running with "http" as the transport mode. I changed that to "binary" and pyhive worked like a charm. Hope this helps some1

Look at hive.server2.transport.mode config (am pulling from memory.. you can always goog and find out) Good Luck!

Quanjiang commented 5 years ago

I have the same problem here. And hive.server2.transport.mode was set to "binary" the issue was same.

Need help ~

Quanjiang commented 5 years ago

My mistake should use HiveServer2 Port as the port, not the hive port information.

abhay7891 commented 5 years ago

I am still getting the same error when I try to connect hive service. I have followed every step as mentioned above (even commented by @Quanjiang @Sarnath below are lib versions - PyHive 0.6.1 thrift 0.11.0 thrift-sasl 0.3.0 sasl 0.2.1

Python version - 3.6.5 GCC 7.2.0 on Linux

Help/assistance needed as I am stuck here, tried all sort of possibilities wherever I have found.

abhay7891 commented 5 years ago

@jingw Please suggest https://github.com/dropbox/PyHive/issues/202#issuecomment-490030976

AndreyEmelyanenko commented 4 years ago

facing the same error just now. @abhay7891 have you found the solution?