user2264738
user2264738

Reputation: 322

Python requests get call getting in to unlimited waiting, where curl succeeds

In our legacy application we use Python2.6 with requests 2.9.1 for making API requests. There a strange behavior is noticed with Python requests library that is, it gets in to unlimited wait where curl requests succeeds

curl https://url # getting 200 response

Wherein,

import requests
requests.get('https://url', verify=False) # getting in to unlimited waiting if no timeout is mentioned.

The same URL is working from the browsers as well, not able to figure out the reason behind it

System Info

curl Requests

# curl 'https://b3-reader.ew1-wip.umm.is-pr.com/abcd/healthstatus' -vvv
* About to connect() to b3-reader.ew1-wip.umm.is-pr.com port 443 (#0)
*   Trying <IP>... connected
* Connected to b3-reader.ew1-wip.umm.is-pr.com (<IP>) port 443 (#0)
* Initializing NSS with certpath: sql:/etc/pki/nssdb
*   CAfile: /etc/pki/tls/certs/ca-bundle.crt
  CApath: none
* SSL connection using TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
* Server certificate:
*       subject: CN=ew1-wip.umm.is-pr.com
*       start date: May 29 00:00:00 2024 GMT
*       expire date: Jun 27 23:59:59 2025 GMT
*       common name: ew1-wip.umm.is-pr.com
*       issuer: CN=Amazon RSA 2048 M03,O=Amazon,C=US
> GET /abcd/healthstatus HTTP/1.1
> User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.44 zlib/1.2.3 libidn/1.18 libssh2/1.4.2
> Host: b3-reader.ew1-wip.umm.is-pr.com
> Accept: */*
>
< HTTP/1.1 200 OK
< Date: Thu, 20 Jun 2024 02:57:58 GMT
< Content-Type: application/json; charset=utf-8
< Transfer-Encoding: chunked
< Connection: keep-alive
< X-Content-Type-Options: nosniff
< X-Frame-Options: SAMEORIGIN
< Content-Security-Policy: frame-src 'self';
<
* Connection #0 to host b3-reader.ew1-wip.umm.is-pr.com left intact
* Closing connection #0

NOTE: Some information's above are masked..

Error info when the wait is interrupted

/usr/lib/python2.6/site-packages/requests/packages/urllib3/util/ssl_.py:315: SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#snimissingwarning.
  SNIMissingWarning
/usr/lib/python2.6/site-packages/requests/packages/urllib3/util/ssl_.py:120: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
^CTraceback (most recent call last):
  File "ping-test.py", line 14, in <module>
    response = requests.get(url,verify=False)
  File "/usr/lib/python2.6/site-packages/requests/api.py", line 67, in get
    return request('get', url, params=params, **kwargs)
  File "/usr/lib/python2.6/site-packages/requests/api.py", line 53, in request
    return session.request(method=method, url=url, **kwargs)
  File "/usr/lib/python2.6/site-packages/requests/sessions.py", line 468, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/lib/python2.6/site-packages/requests/sessions.py", line 576, in send
    r = adapter.send(request, **kwargs)
  File "/usr/lib/python2.6/site-packages/requests/adapters.py", line 376, in send
    timeout=timeout
  File "/usr/lib/python2.6/site-packages/requests/packages/urllib3/connectionpool.py", line 560, in urlopen
    body=body, headers=headers)
  File "/usr/lib/python2.6/site-packages/requests/packages/urllib3/connectionpool.py", line 345, in _make_request
    self._validate_conn(conn)
  File "/usr/lib/python2.6/site-packages/requests/packages/urllib3/connectionpool.py", line 785, in _validate_conn
    conn.connect()
  File "/usr/lib/python2.6/site-packages/requests/packages/urllib3/connection.py", line 252, in connect
    ssl_version=resolved_ssl_version)
  File "/usr/lib/python2.6/site-packages/requests/packages/urllib3/util/ssl_.py", line 317, in ssl_wrap_socket
    return context.wrap_socket(sock)
  File "/usr/lib/python2.6/site-packages/requests/packages/urllib3/util/ssl_.py", line 132, in wrap_socket
    return wrap_socket(socket, **kwargs)
  File "/usr/lib64/python2.6/ssl.py", line 341, in wrap_socket
    suppress_ragged_eofs=suppress_ragged_eofs)
  File "/usr/lib64/python2.6/ssl.py", line 120, in __init__
    self.do_handshake()
  File "/usr/lib64/python2.6/ssl.py", line 279, in do_handshake
    self._sslobj.do_handshake()
KeyboardInterrupt

Upvotes: 0

Views: 57

Answers (0)

Related Questions