0

I am getting "EOFError()" error while connecting to remove hiveserver2. My pyhive version is 0.6.1

hiveserver2 is using http as the transport mode

This is the exception ile "<stdin>", line 1, in <module> File "/usr/local/lib/python2.7/dist-packages/pyhive/hive.py", line 94, in connect return Connection(*args, **kwargs) File "/usr/local/lib/python2.7/dist-packages/pyhive/hive.py", line 198, in __init__ response = self._client.OpenSession(open_session_req) File "/usr/local/lib/python2.7/dist-packages/TCLIService/TCLIService.py", line 187, in OpenSession return self.recv_OpenSession() File "/usr/local/lib/python2.7/dist-packages/TCLIService/TCLIService.py", line 199, in recv_OpenSession (fname, mtype, rseqid) = iprot.readMessageBegin() File "/usr/local/lib/python2.7/dist-packages/thrift/protocol/TBinaryProtocol.py", line 148, in readMessageBegin name = self.trans.readAll(sz) File "/usr/local/lib/python2.7/dist-packages/thrift/transport/TTransport.py", line 65, in readAll raise EOFError()

Also here is the code I am using to connect to remove hive

from pyhive import hive
from thrift.transport import THttpClient
host = 'xxx'
scheme = 'http'
path = '/cliservice'
port = ':' + str(10001)
http_uri = "{}://{}{}{}".format(scheme, host, port, path)
transport = THttpClient.THttpClient(http_uri)

username = 'xxx'
password = ''
if username or password:
    auth = base64.b64encode(username + ':' + password)
    transport.setCustomHeaders({'Authorization': 'Basic ' + auth})
connection = hive.connect(thrift_transport=transport)
Nipun
  • 4,119
  • 5
  • 47
  • 83

1 Answers1

1

pyhive has a simple connect method, did you give if a try.

from pyhive import hive
connection = hive.connect(host='HIVE_HOST',
                          port=10000,
                          database='temp',
                          username='HIVE_USERNAME',
                          password='HIVE_PASSWORD',
                          auth='CUSTOM')    
Gaurang Shah
  • 11,764
  • 9
  • 74
  • 137
  • 1
    This uses the binary mode of thrift.. but I am using http mode – Nipun Dec 29 '18 at 05:44
  • 1
    Anyone found a solution for this? I'm getting same exception for similar setup. I have a sslTrustStore and sslTrustStorePassword parameters and I can connect successfully via beehive. The only difference is I'm trying to connect using overridden THttpClient constructor. ```transport = THttpClient.THttpClient(uri_or_host=host, port=port, path='cliservice', ssl_context=ssl_context)``` here ssl_context is `check_hostname=False` and `verify_mode=ssl.CERT_NONE` – Anirban Kundu Apr 13 '20 at 04:47