<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Splunk Python SDK failing with BadStatusLine error in Splunk Dev</title>
    <link>https://community.splunk.com/t5/Splunk-Dev/Splunk-Python-SDK-failing-with-BadStatusLine-error/m-p/239250#M3031</link>
    <description>&lt;P&gt;Can you show me the code you're using complete with the server address etc. ?&lt;/P&gt;

&lt;P&gt;Please mask the domain or IP address but I'm interested in the port numbers, and the syntax and the actual code.&lt;/P&gt;</description>
    <pubDate>Thu, 10 Mar 2016 00:04:02 GMT</pubDate>
    <dc:creator>jkat54</dc:creator>
    <dc:date>2016-03-10T00:04:02Z</dc:date>
    <item>
      <title>Splunk Python SDK failing with BadStatusLine error</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Splunk-Python-SDK-failing-with-BadStatusLine-error/m-p/239247#M3028</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;

&lt;P&gt;I'm having an issue with the Python SDK. I'm running the latest version of the SDK (1.5.0) on python 2.7.10. Whever I try to connect to my instance I get the following error:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Traceback (most recent call last):
  File "event_types.py", line 44, in &amp;lt;module&amp;gt;
    main()
  File "event_types.py", line 32, in main
    service = connect(**opts.kwargs)
  File "..\splunklib\client.py", line 321, in connect
    s.login()
  File "..\splunklib\binding.py", line 847, in login
    cookie="1") # In Splunk 6.2+, passing "cookie=1" will return the "set-cookie" header
  File "..\splunklib\binding.py", line 1185, in post
    return self.request(url, message)
  File "..\splunklib\binding.py", line 1202, in request
    response = self.handler(url, message, **kwargs)
  File "..\splunklib\binding.py", line 1339, in request
    response = connection.getresponse()
  File "C:\Python27\lib\httplib.py", line 1067, in getresponse
    response.begin()
  File "C:\Python27\lib\httplib.py", line 409, in begin
    version, status, reason = self._read_status()
  File "C:\Python27\lib\httplib.py", line 373, in _read_status
    raise BadStatusLine(line)
httplib.BadStatusLine: ''
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I recently upgraded my Python version. Is there any reason that 2.7.10 wouldn't work with the current version of the SDK? Is there a workaround for this error?&lt;/P&gt;

&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 09 Mar 2016 20:11:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Splunk-Python-SDK-failing-with-BadStatusLine-error/m-p/239247#M3028</guid>
      <dc:creator>bruceclarke</dc:creator>
      <dc:date>2016-03-09T20:11:15Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk Python SDK failing with BadStatusLine error</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Splunk-Python-SDK-failing-with-BadStatusLine-error/m-p/239248#M3029</link>
      <description>&lt;P&gt;I'm not 100% sure but I do use Python 2.7.10 myself without issue.  So I don't think the upgrade is the problem.  It could be related because they handle your object a bit differently etc.  It's just unlikely.&lt;/P&gt;

&lt;P&gt;If we focus on the error message, it's says it's getting a bad status message from the httplib request.  Its expecting a code like 2xx,3xx,4xx,5xx (404 page not found for example), but instead it's getting something unexpected and falling into an exception case.  &lt;/P&gt;

&lt;P&gt;I think if you try to use curl from the same affected machine to the same server, you might get more details.  Maybe you'll get a very strange error message related to tcp stack corruption, no route to host, etc.  Can you try curling the server fr the machine and post the response you get?&lt;/P&gt;</description>
      <pubDate>Wed, 09 Mar 2016 22:31:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Splunk-Python-SDK-failing-with-BadStatusLine-error/m-p/239248#M3029</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2016-03-09T22:31:19Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk Python SDK failing with BadStatusLine error</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Splunk-Python-SDK-failing-with-BadStatusLine-error/m-p/239249#M3030</link>
      <description>&lt;P&gt;Ah, so I'm not getting any response when trying to use an http scheme. When I switch to https, the curl works fine, but the SDK still exits with an error. The error is different though:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Traceback (most recent call last):
  File "event_types.py", line 44, in &amp;lt;module&amp;gt;
    main()
  File "event_types.py", line 32, in main
    service = connect(**opts.kwargs)
  File "..\splunklib\client.py", line 321, in connect
    s.login()
  File "..\splunklib\binding.py", line 847, in login
    cookie="1") # In Splunk 6.2+, passing "cookie=1" will return the "set-cookie" header
  File "..\splunklib\binding.py", line 1185, in post
    return self.request(url, message)
  File "..\splunklib\binding.py", line 1202, in request
    response = self.handler(url, message, **kwargs)
  File "..\splunklib\binding.py", line 1334, in request
    connection = connect(scheme, host, port)
  File "..\splunklib\binding.py", line 1317, in connect
    kwargs['context'] = ssl._create_unverified_context()
AttributeError: 'module' object has no attribute '_create_unverified_context'
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Do I need to update a separate package for compatibility with the Splunk SDK?&lt;/P&gt;</description>
      <pubDate>Wed, 09 Mar 2016 22:42:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Splunk-Python-SDK-failing-with-BadStatusLine-error/m-p/239249#M3030</guid>
      <dc:creator>bruceclarke</dc:creator>
      <dc:date>2016-03-09T22:42:55Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk Python SDK failing with BadStatusLine error</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Splunk-Python-SDK-failing-with-BadStatusLine-error/m-p/239250#M3031</link>
      <description>&lt;P&gt;Can you show me the code you're using complete with the server address etc. ?&lt;/P&gt;

&lt;P&gt;Please mask the domain or IP address but I'm interested in the port numbers, and the syntax and the actual code.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Mar 2016 00:04:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Splunk-Python-SDK-failing-with-BadStatusLine-error/m-p/239250#M3031</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2016-03-10T00:04:02Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk Python SDK failing with BadStatusLine error</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Splunk-Python-SDK-failing-with-BadStatusLine-error/m-p/239251#M3032</link>
      <description>&lt;P&gt;I'm just running the event_types.py file (under the examples folder with the Splunk SDK release) with my environment variables specified.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;import sys, os
sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))

from splunklib.client import connect

try:
    from utils import parse
except ImportError:
    raise Exception("Add the SDK repository to your PYTHONPATH to run the examples "
                    "(e.g., export PYTHONPATH=~/splunk-sdk-python.")

def main():
    opts = parse(sys.argv[1:], {}, ".splunkrc")
    service = connect(**opts.kwargs)

    for item in service.event_types:
        print "%s" % item.name
        print '='*len(item.name)
        content = item.content
        for key in sorted(content.keys()):
            value = content[key]
            print "%s: %s" % (key, value)
        print

if __name__ == "__main__":
    main()
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Here is what is in my .splunkrc file:&lt;BR /&gt;
    host=mySplunk&lt;BR /&gt;
    port=8089&lt;BR /&gt;
    username=admin&lt;BR /&gt;
    password=myPassword&lt;BR /&gt;
    scheme=https&lt;BR /&gt;
    version=6.3&lt;/P&gt;</description>
      <pubDate>Thu, 10 Mar 2016 00:23:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Splunk-Python-SDK-failing-with-BadStatusLine-error/m-p/239251#M3032</guid>
      <dc:creator>bruceclarke</dc:creator>
      <dc:date>2016-03-10T00:23:16Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk Python SDK failing with BadStatusLine error</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Splunk-Python-SDK-failing-with-BadStatusLine-error/m-p/239252#M3033</link>
      <description>&lt;P&gt;Ah, it's failing based on your opts.kwargs (which is read from you .splunkrc file).&lt;/P&gt;

&lt;P&gt;File "event_types.py", line 32, in main&lt;BR /&gt;
     service = connect(**opts.kwargs)&lt;/P&gt;

&lt;P&gt;Sorry but I was on a mobile phone earlier.  Something in your keyword arguments maybe isnt "cool".&lt;/P&gt;

&lt;P&gt;Do you have a strong password with special characters etc?  If so, try surrounding the values with single or double quotes like this:&lt;/P&gt;

&lt;P&gt;host='myhost'&lt;BR /&gt;
port='8089'&lt;BR /&gt;
username='admin'&lt;BR /&gt;
password='my$pec!@lP@ssw0rd!'&lt;BR /&gt;
scheme=https #&amp;lt;-unfortunately I dont know if this is correct, maybe needs to be ssl, im looking at httplib2 now (what splunk uses in the connect() function)&lt;BR /&gt;
version=6.3  #&amp;lt;-unfortunately I dont know if its needed, maybe try commenting it out and testing&lt;/P&gt;</description>
      <pubDate>Thu, 10 Mar 2016 01:23:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Splunk-Python-SDK-failing-with-BadStatusLine-error/m-p/239252#M3033</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2016-03-10T01:23:32Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk Python SDK failing with BadStatusLine error</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Splunk-Python-SDK-failing-with-BadStatusLine-error/m-p/239253#M3034</link>
      <description>&lt;P&gt;No difference, unfortunately. I still get the same error on the same line.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Mar 2016 01:33:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Splunk-Python-SDK-failing-with-BadStatusLine-error/m-p/239253#M3034</guid>
      <dc:creator>bruceclarke</dc:creator>
      <dc:date>2016-03-10T01:33:03Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk Python SDK failing with BadStatusLine error</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Splunk-Python-SDK-failing-with-BadStatusLine-error/m-p/239254#M3035</link>
      <description>&lt;P&gt;Hey, are you using splunk free for this?  If so, i think that is the problem.  Looks like this can be related to unsupported ssl ciphers that are used in the trial version.  You can download a splunk enterprise trial and test with it instead if so.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Mar 2016 01:33:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Splunk-Python-SDK-failing-with-BadStatusLine-error/m-p/239254#M3035</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2016-03-10T01:33:34Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk Python SDK failing with BadStatusLine error</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Splunk-Python-SDK-failing-with-BadStatusLine-error/m-p/239255#M3036</link>
      <description>&lt;P&gt;I'm using a full enterprise instance.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Mar 2016 01:46:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Splunk-Python-SDK-failing-with-BadStatusLine-error/m-p/239255#M3036</guid>
      <dc:creator>bruceclarke</dc:creator>
      <dc:date>2016-03-10T01:46:39Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk Python SDK failing with BadStatusLine error</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Splunk-Python-SDK-failing-with-BadStatusLine-error/m-p/239256#M3037</link>
      <description>&lt;P&gt;@jkat54 Thanks for all the help here. I upgraded to Python 2.7.11 and it seems to have fixed the issue. Still unclear what might have been fixed in the upgrade, but I assume it's something in the ssl module.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Mar 2016 04:41:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Splunk-Python-SDK-failing-with-BadStatusLine-error/m-p/239256#M3037</guid>
      <dc:creator>bruceclarke</dc:creator>
      <dc:date>2016-03-10T04:41:30Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk Python SDK failing with BadStatusLine error</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Splunk-Python-SDK-failing-with-BadStatusLine-error/m-p/239257#M3038</link>
      <description>&lt;P&gt;It turns out that updating to Python 2.7.11 fixed the issue. I'm not sure what bug fix might have been addressed in the minor upgrade, but at least we're in a working state now.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Mar 2016 04:42:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Splunk-Python-SDK-failing-with-BadStatusLine-error/m-p/239257#M3038</guid>
      <dc:creator>bruceclarke</dc:creator>
      <dc:date>2016-03-10T04:42:13Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk Python SDK failing with BadStatusLine error</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Splunk-Python-SDK-failing-with-BadStatusLine-error/m-p/239258#M3039</link>
      <description>&lt;P&gt;Didnt see that one coming... good work on the solution!  Thanks for working with me!&lt;/P&gt;</description>
      <pubDate>Thu, 10 Mar 2016 05:09:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Splunk-Python-SDK-failing-with-BadStatusLine-error/m-p/239258#M3039</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2016-03-10T05:09:26Z</dc:date>
    </item>
  </channel>
</rss>

