OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Python requests get call fails where curl succeeds

  • Thread starter Thread starter user2264738
  • Start date Start date
U

user2264738

Guest
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 fails where curl requests succeeds

Code:
curl https://url # getting 200 response

Wherein,

Code:
import requests
requests.get('https://url', verify=False) # fails with read timeout.

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

System Info

  • CentOS release 6.10 (Final)
  • Python 2.6.6
  • requests 2.9.1

Code:
# 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..
<p>In our legacy application we use Python2.6 with <strong>requests 2.9.1</strong> for making API requests.
There a strange behavior is noticed with Python requests library that is, it fails where <strong>curl</strong> requests succeeds</p>
<pre><code>curl https://url # getting 200 response
</code></pre>
<p>Wherein,</p>
<pre><code>import requests
requests.get('https://url', verify=False) # fails with read timeout.
</code></pre>
<p>The same URL is working from the browsers as well, not able to figure out the reason behind it</p>
<p>System Info</p>
<ul>
<li>CentOS release 6.10 (Final)</li>
<li>Python 2.6.6</li>
<li>requests 2.9.1</li>
</ul>
<pre><code># 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
</code></pre>
<p>NOTE: <em>Some information's above are masked..</em></p>
 

Latest posts

Top