5

I have tested a 'POST' request with both PoolManager and HTTPSConnectionPool. The first one works, the other throw me a :

urllib3.exceptions.MaxRetryError: 
HTTPSConnectionPool(host='https://some.url.com', port=443): 
Max retries exceeded with url: /some-api (Caused by <class 'socket.gaierror'>:
[Errno -2] Name or service not known)

Here's my code for PoolManager:

import urllib3

HOST = 'https://some.url.com'
PORT = 443
PATH = '/some-api'
xml_request = '<some xml tree/>'

manager = urllib3.PoolManager()
res = manager.request('POST', HOST+PATH, {'req':xml_request})

and for HTTPSConnectonPool:

manager = urllib3.HTTPSConnectionPool(HOST, port=PORT)
res = manager.request('POST', PATH, {'req':xml_request})
Yann
  • 134
  • 1
  • 11

1 Answers1

5

https://some.url.com is not a hostname or IP address, it's a URL. So you're feeding the wrong information to HTTPSConnectionPool.

Furthermore, PoolManager and HTTPSConnectionPool are not at the same abstraction level. PoolManager manages ConnectionPool instances for you.

MattH
  • 37,273
  • 11
  • 82
  • 84
  • Thanks for the tip ! I know those are different, and that's why I tried HTTPSConnectionPool first (cause I don't have to manage many pools). – Yann Jun 11 '14 at 10:37
  • While this is a good answer and it is safe to use PoolManager in this instance with no downsides, @Yann's original question should function properly if we change the `HOST` to `some.url.com` (without the `https://`). – shazow Jun 11 '14 at 16:24
  • @shazow this is what I implied by my first sentence – MattH Jun 11 '14 at 17:44