Splunk Dev

Getting error and connection failure using client.connect.

dvuichor
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 failed 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.send_request(method, url, body, headers)
File "/u01/Anaconda/Anaconda25/lib/python2.7/httplib.py", line 1082, in _send_request
self.endheaders(body)
File "/u01/Anaconda/Anaconda25/lib/python2.7/httplib.py", line 1038, in endheaders
self._send_output(message_body)
File "/u01/Anaconda/Anaconda25/lib/python2.7/httplib.py", line 882, in _send_output
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
server_hostname=server_hostname)
File "/u01/Anaconda/Anaconda25/lib/python2.7/ssl.py", line 363, in wrap_socket
_context=self)
File "/u01/Anaconda/Anaconda25/lib/python2.7/ssl.py", line 611, in __init
_
self.do_handshake()
File "/u01/Anaconda/Anaconda25/lib/python2.7/ssl.py", line 840, in do_handshake
self._sslobj.do_handshake()
ssl.SSLError: [SSL: UNKNOWN_PROTOCOL] unknown protocol (_ssl.c:661)

what did i do wrong?

Labels (1)
0 Karma
1 Solution

kamlesh_vaghela
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

dvuichor
New Member

Hi,
that fixed my issue

Thanks for your help

0 Karma

kamlesh_vaghela
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

0 Karma

shahid285
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

kamlesh_vaghela
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

kamlesh_vaghela
SplunkTrust
SplunkTrust

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

!!!! Happy Splunking !!!!

0 Karma

dvuichor
New Member

thanks for your help!

0 Karma

chandrasekharko
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: CERTIFICATE_VERIFY_FAILED] 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
Get Updates on the Splunk Community!

Let’s Talk Terraform

If you’re beyond the first-weeks-of-a-startup stage, chances are your application’s architecture is pretty ...

Cloud Platform | Customer Change Announcement: Email Notification is Available For ...

The Notification Team is migrating our email service provider. As the rollout progresses, Splunk has enabled ...

Save the Date: GovSummit Returns Wednesday, December 11th!

Hey there, Splunk Community! Exciting news: Splunk’s GovSummit 2024 is returning to Washington, D.C. on ...