1

Has anyone experienced this error before when trying to connect to hive.

Sample code used (https://github.com/telefonicaid/fiware-cygnus/blob/master/cygnus-ngsi/resources/hiveclients/python/hiveserver2-client.py):

import sys
import pyhs2
from pyhs2.error import Pyhs2Exception

# get the input parameters
if len(sys.argv) != 6:
    print 'Usage: python hiveserver2-client.py <hive_host> <hive_port> <db_name> <hadoop_user> <hadoop_password>'
    sys.exit()

hiveHost = sys.argv[1]
hivePort = sys.argv[2]
dbName = sys.argv[3]
hadoopUser = sys.argv[4]
hadoopPassword = sys.argv[5]

# do the connection
with pyhs2.connect(host=hiveHost,
                   port=hivePort,
                   authMechanism="PLAIN",
                   user=hadoopUser,
                   password=hadoopPassword,
                   database=dbName) as conn:
    # get a client
    with conn.cursor() as client:
        # create a loop attending HiveQL queries
        while (1):
            query = raw_input('remotehive> ')

            try:
                if not query:
                    continue

                if query == 'exit':
                    sys.exit()

                # execute the query
                client.execute(query)

                # get the content
                for row in client.fetch():
                    print row

            except Pyhs2Exception, ex:
                print ex.errorMessage

Error displayed:

[centos@test]$ sudo python hiveserver2-client.py computing.cosmos.lab.fiware.org 10000 default USERNAME TOKEN
Traceback (most recent call last):
  File "hiveserver2-client.py", line 42, in <module>
    database=dbName) as conn:
  File "/usr/lib/python2.7/site-packages/pyhs2/__init__.py", line 7, in connect
    return Connection(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/pyhs2/connections.py", line 46, in __init__
    transport.open()
  File "/usr/lib/python2.7/site-packages/pyhs2/cloudera/thrift_sasl.py", line 74, in open
    status, payload = self._recv_sasl_message()
  File "/usr/lib/python2.7/site-packages/pyhs2/cloudera/thrift_sasl.py", line 92, in _recv_sasl_message
    header = self._trans.readAll(5)
  File "/usr/lib/python2.7/site-packages/thrift/transport/TTransport.py", line 60, in readAll
    chunk = self.read(sz - have)
  File "/usr/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

1 Answer 1

0

can you post your piece of code ? This looks like some auth mechanism or credentials sent are not Valid.

authMechanism= can be "PLAIN" or "KERBEROS" as per your setup .

2
  • thanks for replying, I'm using PLAIN as authMechanism. I just updated the question with the code I'm using.
    – netzahdzc
    Mar 1, 2017 at 15:39
  • This error could be caused by maintenance activities in FIWARE Lab. Please, check it again. Currentyly, it seems to be working.
    – frb
    Mar 1, 2017 at 16:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.