Connection Issue: thrift.transport.TTransport.TTransportException: TSocket read 0 bytes
Opened this issue · 12 comments
I followed the example.py but I am stil having issues connecting to Hive.
example.py seems straight forward enough so I'm not sure where I went wrong.
>>> import pyhs2
>>> pyhs2.connect(host=host_server, port=8088, authMechanism="PLAIN", user=username, password=password, database=database)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Python/2.7/site-packages/pyhs2/__init__.py", line 7, in connect
return Connection(*args, **kwargs)
File "/Library/Python/2.7/site-packages/pyhs2/connections.py", line 46, in __init__
transport.open()
File "/Library/Python/2.7/site-packages/pyhs2/cloudera/thrift_sasl.py", line 74, in open
status, payload = self._recv_sasl_message()
File "/Library/Python/2.7/site-packages/pyhs2/cloudera/thrift_sasl.py", line 95, in _recv_sasl_message
payload = self._trans.readAll(length)
File "/Library/Python/2.7/site-packages/thrift/transport/TTransport.py", line 58, in readAll
chunk = self.read(sz - have)
File "/Library/Python/2.7/site-packages/thrift/transport/TSocket.py", line 120, in read
message='TSocket read 0 bytes')
thrift.transport.TTransport.TTransportException: TSocket read 0 bytes
Have you ever managed to solve this error? I have the same problem. I'm trying to connect to my hortonworks sandbox running locally.
@dsmits Did you resolve it? I am facing same error, although I am using kerberos authentication.
@gerlachry What fixed it for me is to reset the hive configuration on my sandbox back to defaults. It worked fine after that.
@dsmits What configs exactly fixed it? I am trying to connect to our production cluster and it is giving me the error above and I am not in control of the cluster. I am going to need to know what configs affect this if I am going to make the request. Any help would be greatly appreciated.
Did anybody fix this ! Am facing this error when connecting to production hive server !
fix it ? same problem
Did anybody fix this !Need help
same problem, who can help me ?
I had the same problem with pyhs2 and pyhive. My python script had some initial differences though. I had the authMechanism="NOSASL"
and I was using port=10000
in my python script.
I changed the hive.server2.authentication
configuration on ambari to NOSASL
. If you are not using ambari then you should be able to change the hive.server2.authentication
parameter in a configuration file called hive-site.xml
.
I then restarted hive and any other services that needed to be restarted.
This seemed to fix the issues I was having.
I had the same problem where the python program will simply fail with this error message immediately... So, that was 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 some! Check dropbox/PyHive#69
I think the config name is hive.server2.transport.mode . Set that to "binary" and PyHive will be fine. But ensure that other apps dont break while you are changing this setting! :) GOod Luck!
In my case, the error comes even if the transport mode is "binary". What else can be the issue?
I set authMechanism
to NOSASL
, in hive-site.xml, set hive.server2.authentication
to NOSASL
, then,problom solved.
with pyhs2.connect(host='yourip',
port=10000,
authMechanism="NOSASL",
user='username setted in hive-site.xml',
password='password setted in hive-site.xml',
database='default') as conn:
Pyhs2 is no longer being maintained, so PyHive is also good choice.But it need to set hive.server2.transport.mode
to 'binary'.
Forgive me for my plastic English. 😬