Reputation: 833
I am trying to connect to impala using impyla, each time I am getting this error
Could not start SASL: b'Error in sasl_client_start (-4) SASL(-4): no mechanism available: Unable to find a callback: 2'
I have installed:
impyla==0.16.2
thrift_sasl==0.4.2
thrift==0.13.0
thriftpy==0.3.9
thriftpy2==0.4.11
I am connecting using
connect = connect(host=server, port=21050, user=login, password=passwd, use_ssl=True, auth_mechanism='LDAP')
I used this previously on python 2.7 and it was working, now when i moved to 3.6 it stopped.
edit: I was digging little bit more and it seems that thrift_sasl is not recognising 'LDAP' authentication
TTransportException Traceback (most recent call last)
<ipython-input-4-562dbef67d96> in <module>
7 select_offset = 0
8
----> 9 connect = connect(host='azrudb7006.ra.rockwell.com', port=21050, database=db_name, user=login, password=passwd, use_ssl=True, auth_mechanism="LDAP")
~\Anaconda3\envs\py36\lib\site-packages\impala\dbapi.py in connect(host, port, database, timeout, use_ssl, ca_cert, auth_mechanism, user, password, kerberos_service_name, use_ldap, ldap_user, ldap_password, use_kerberos, protocol, krb_host, use_http_transport, http_path)
148 auth_mechanism=auth_mechanism, krb_host=krb_host,
149 use_http_transport=use_http_transport,
--> 150 http_path=http_path)
151 return hs2.HiveServer2Connection(service, default_db=database)
152
~\Anaconda3\envs\py36\lib\site-packages\impala\hiveserver2.py in connect(host, port, timeout, use_ssl, ca_cert, user, password, kerberos_service_name, auth_mechanism, krb_host, use_http_transport, http_path)
823 auth_mechanism, user, password)
824
--> 825 transport.open()
826 protocol = TBinaryProtocol(transport)
827 if six.PY2:
~\Anaconda3\envs\py36\lib\site-packages\thrift_sasl\__init__.py in open(self)
94 if status not in (self.OK, self.COMPLETE):
95 raise TTransportException(type=TTransportException.NOT_OPEN,
---> 96 message=("Bad status: %d (%s)" % (status, payload)))
97 if status == self.COMPLETE:
98 break
TTransportException: Bad status: 3 (b'Unsupported mechanism type ')
Upvotes: 0
Views: 6895
Reputation: 550
I also encountered this error. The only solution is to remove sasl and use pure-sasl.
My requirements:
thrift-sasl==0.4.2
pure-sasl==0.6.2
impyla==0.16.3
For Windows, sasl is not installed and therefore can work without problems, but on Linux machines it needs to be removed (pulled up inside thrift_sasl) otherwise, the factory for connecting via sasl does not work correctly inside the impyla library.
It also allows you to get rid of the error: TProtocolException No protocol version header
My realization:
from impala.dbapi import connect
from impala.hiveserver2 import HiveServer2Connection
from config import Config
def init_connection():
auth_mechanism = 'PLAIN'
return connect(host=Config.HIVE_HOST,
port=Config.HIVE_PORT,
user=Config.HIVE_USER,
auth_mechanism=auth_mechanism)
class PyHive:
conn: HiveServer2Connection = init_connection()
def __init__(self):
self.cursor = self.conn.cursor()
def __enter__(self):
return self.cursor
def __exit__(self, exc_type, exc_val, exc_tb):
self.cursor.close()
Upvotes: 0