Getting Data In

Why am I getting this error trying to create a connection with my environment using the Python SDK?

rafamss
Contributor

Hi guys,

I'm using the sample script to connect with my environment using the Splunk Python SDK. For the development environment this works, but for the production environment, it doesn't work. Both endpoints of Splunk use https for connection.

Following the code:

import splunklib.client as client

HOST = "myEndPoint"
PORT = 8089
USERNAME = "admin"
PASSWORD = "changeme"

# Create a Service instance and log in 
service = client.connect(
    host=HOST,
    port=PORT,
    username=USERNAME,
    password=PASSWORD)

# Print installed apps to the console to verify login
for app in service.apps:
    print app.name 

Traceback:

Traceback (most recent call last):
  File "C:\Users\rmshzol\PycharmProjects\splunk-sdk\splunk_Connet.py", line 13, in 
    password=PASSWORD)
  File "C:\Users\rmshzol\PycharmProjects\splunk-sdk\splunklib\client.py", line 321, in connect
    s.login()
  File "C:\Users\rmshzol\PycharmProjects\splunk-sdk\splunklib\binding.py", line 857, in login
    cookie="1") # In Splunk 6.2+, passing "cookie=1" will return the "set-cookie" header
  File "C:\Users\rmshzol\PycharmProjects\splunk-sdk\splunklib\binding.py", line 1201, in post
    return self.request(url, message)
  File "C:\Users\rmshzol\PycharmProjects\splunk-sdk\splunklib\binding.py", line 1218, in request
    response = self.handler(url, message, **kwargs)
  File "C:\Users\rmshzol\PycharmProjects\splunk-sdk\splunklib\binding.py", line 1357, in request
    connection.request(method, path, body, head)
  File "C:\Users\rmshzol\PycharmProjects\splunk-sdk\httplib.py", line 1057, in request
    self._send_request(method, url, body, headers)
  File "C:\Users\rmshzol\PycharmProjects\splunk-sdk\httplib.py", line 1097, in _send_request
    self.endheaders(body)
  File "C:\Users\rmshzol\PycharmProjects\splunk-sdk\httplib.py", line 1053, in endheaders
    self._send_output(message_body)
  File "C:\Users\rmshzol\PycharmProjects\splunk-sdk\httplib.py", line 897, in _send_output
    self.send(msg)
  File "C:\Users\rmshzol\PycharmProjects\splunk-sdk\httplib.py", line 859, in send
    self.connect()
  File "C:\Users\rmshzol\PycharmProjects\splunk-sdk\httplib.py", line 1270, in connect
    HTTPConnection.connect(self)
  File "C:\Users\rmshzol\PycharmProjects\splunk-sdk\httplib.py", line 836, in connect
    self.timeout, self.source_address)
  File "C:\Python27\lib\socket.py", line 575, in create_connection
    raise err
socket.error: [Finished in 21.6s]
0 Karma
1 Solution

rafamss
Contributor

Hi guys,

This error stoped of occur magically 🙂. I believe that I was blocked for any rule in my network.

View solution in original post

0 Karma

rafamss
Contributor

Hi guys,

This error stoped of occur magically 🙂. I believe that I was blocked for any rule in my network.

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Take Action Automatically on Splunk Alerts with Red Hat Ansible Automation Platform

 Are you ready to revolutionize your IT operations? As digital transformation accelerates, the demand for ...

Calling All Security Pros: Ready to Race Through Boston?

Hey Splunkers, .conf25 is heading to Boston and we’re kicking things off with something bold, competitive, and ...

Beyond Detection: How Splunk and Cisco Integrated Security Platforms Transform ...

Financial services organizations face an impossible equation: maintain 99.9% uptime for mission-critical ...