splunk-sdk-python icon indicating copy to clipboard operation
splunk-sdk-python copied to clipboard

client port should be passed to httplib as integer not string

Open bcavagnolo opened this issue 13 years ago • 3 comments

When I pass an unresolved hostname to client.connect, I get an exception:

<snip>
  File "/usr/local/lib/python2.7/dist-packages/splunklib/client.py", line 288, in connect
    return Service(**kwargs).login()
  File "/usr/local/lib/python2.7/dist-packages/splunklib/binding.py", line 751, in login
    password=self.password)
  File "/usr/local/lib/python2.7/dist-packages/splunklib/binding.py", line 1079, in post
    return self.request(url, message)
  File "/usr/local/lib/python2.7/dist-packages/splunklib/binding.py", line 1096, in request
    response = self.handler(url, message, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/splunklib/binding.py", line 1195, in request
    connection.request(method, path, body, head)
  File "/usr/lib/python2.7/httplib.py", line 958, in request
    self._send_request(method, url, body, headers)
  File "/usr/lib/python2.7/httplib.py", line 992, in _send_request
    self.endheaders(body)
  File "/usr/lib/python2.7/httplib.py", line 954, in endheaders
    self._send_output(message_body)
  File "/usr/lib/python2.7/httplib.py", line 814, in _send_output
    self.send(msg)
  File "/usr/lib/python2.7/httplib.py", line 776, in send
    self.connect()
  File "/usr/lib/python2.7/httplib.py", line 1157, in connect
    self.timeout, self.source_address)
  File "/usr/local/lib/python2.7/dist-packages/gevent/socket.py", line 637, in create_connection
    for res in getaddrinfo(host, port, 0, SOCK_STREAM):
  File "/usr/local/lib/python2.7/dist-packages/gevent/socket.py", line 737, in getaddrinfo
    raise gaierror(EAI_SERVICE, 'Servname not supported for ai_socktype')
socket.gaierror: [Errno -8] Servname not supported for ai_socktype

binding.py:hander.request extracts the port as a string from a url argument. This gets passed down the stack eventually (on my system, anyway) to gevent/socket.py. getaddrinfo sees the port as a string and tries to look it up in /etc/services instead of accepting it as an integer.

bcavagnolo avatar Jul 30 '13 12:07 bcavagnolo

I cannot re-create this error. Is this still a problem? Can you post the parameters you used in client.connect?

stelles avatar Jul 09 '14 18:07 stelles

I'm not sure if this is still a problem or not. I'm not using the splunk sdk anymore.

bcavagnolo avatar Jul 09 '14 19:07 bcavagnolo

Thanks anyway.

stelles avatar Jul 09 '14 19:07 stelles