Developing for Splunk Enterprise
Highlighted

Getting error and connection failure using client.connect.

New Member

Here is my code:
Import splunklib.client as client:

HOST = "myhost"
PORT = 8000
USERNAME = "admin"
PASSWORD = "mypassword"

Create a Service instance and log in

service = client.connect(
host=HOST,
port=PORT,
username=USERNAME,
password=PASSWORD)

When I execute it fails with these errors:

Traceback (most recent call last):
File "testconn.py", line 13, in 
password=PASSWORD)
File "/u01/software/splunk/software/splunk-sdk-python-1.6.3/splunklib/client.py", line 322, in connect
s.login()
File "/u01/software/splunk/software/splunk-sdk-python-1.6.3/splunklib/binding.py", line 859, in login
cookie="1") # In Splunk 6.2+, passing "cookie=1" will return the "set-cookie" header
File "/u01/software/splunk/software/splunk-sdk-python-1.6.3/splunklib/binding.py", line 1204, in post
return self.request(url, message)
File "/u01/software/splunk/software/splunk-sdk-python-1.6.3/splunklib/binding.py", line 1221, in request
response = self.handler(url, message, **kwargs)
File "/u01/software/splunk/software/splunk-sdk-python-1.6.3/splunklib/binding.py", line 1360, in request
connection.request(method, path, body, head)
File "/u01/Anaconda/Anaconda25/lib/python2.7/httplib.py", line 1042, in request
self.sendrequest(method, url, body, headers)
File "/u01/Anaconda/Anaconda25/lib/python2.7/httplib.py", line 1082, in sendrequest
self.endheaders(body)
File "/u01/Anaconda/Anaconda25/lib/python2.7/httplib.py", line 1038, in endheaders
self.sendoutput(messagebody)
File "/u01/Anaconda/Anaconda25/lib/python2.7/httplib.py", line 882, in _sendoutput
self.send(msg)
File "/u01/Anaconda/Anaconda25/lib/python2.7/httplib.py", line 844, in send
self.connect()
File "/u01/Anaconda/Anaconda25/lib/python2.7/httplib.py", line 1263, in connect
serverhostname=serverhostname)
File "/u01/Anaconda/Anaconda25/lib/python2.7/ssl.py", line 363, in wrapsocket
_context=self)
File "/u01/Anaconda/Anaconda25/lib/python2.7/ssl.py", line 611, in _init__
self.dohandshake()
File "/u01/Anaconda/Anaconda25/lib/python2.7/ssl.py", line 840, in dohandshake
self.sslobj.dohandshake()
ssl.SSLError: [SSL: UNKNOWNPROTOCOL] unknown protocol (ssl.c:661)

What did I do wrong?

Labels (1)
0 Karma
Highlighted

Re: failed to connect using client.connect

SplunkTrust
SplunkTrust

Hi @dvuichor,

I think you should try 8089 management port.
Can you please see example given in this link?

http://docs.splunk.com/DocumentationStatic/PythonSDK/1.1/client.html
http://dev.splunk.com/view/javascript-sdk/SP-CAAAEC9

Thanks

View solution in original post

0 Karma
Highlighted

Re: failed to connect using client.connect

SplunkTrust
SplunkTrust

Hi @dvuichor,
Great.
Can you please accept the answer to close this question. This will help the community.

!!!! Happy Splunking !!!!

0 Karma
Highlighted

Re: failed to connect using client.connect

New Member

thanks for your help!

0 Karma
Highlighted

Re: failed to connect using client.connect

Path Finder

I have the same issue. But, I used port 8089. But, I am still not able to connect. The error I get is:

ssl.SSLError: [SSL: CERTIFICATEVERIFYFAILED] certificate verify failed (_ssl.c:579)

The code is below for the connection I used. Please guide me on this.

import splunklib.client as client

HOST = "localhost"
PORT = 8089
USERNAME = "admin"
PASSWORD = "Qwerty@1993"

service = client.connect(
host=HOST,
port=PORT,
username=USERNAME,
password=PASSWORD)

for app in service.apps:
print app.name

0 Karma
Highlighted

Re: failed to connect using client.connect

Path Finder

Hi @kamlesh_vaghela ,
I am having the same issue as reported here, but i am using 8089 as a port, and my firewall is aswell down.
I am even able to do a curl , but the script continues to give the same certificate error.

Can you please suggest anything for this?

Thanks
Shahid

0 Karma
Highlighted

Re: failed to connect using client.connect

SplunkTrust
SplunkTrust

@shahid285

Not sure about your exact issue, So can you please refer below link for that?

https://answers.splunk.com/answers/609126/ssl-error-while-trying-to-connect-to-splunk-web-fr.html

0 Karma
Highlighted

Re: failed to connect using client.connect

New Member

Hi,
that fixed my issue

Thanks for your help

0 Karma