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
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Event Series: Splunk Observability Metrics Cost Optimization

Balancing Scale and Spend: Gaining Control Over High-Volume Metrics in Splunk Observability Cloud As ...

Kick the Tires Before You Commit: A Hands-On Tour of the Splunk Observability Cloud ...

Evaluating an enterprise observability platform usually goes like this: fill out a form, get a free trial with ...

Deep insights, no barriers: Splunk Observability Cloud Free Edition

As software delivery cycles continue to accelerate, observability shouldn’t be a luxury — it should be a ...