0

I have a Django 4.2.2 application running on Python 3.11. One of the views is as follows:

import requests
from django.http import HttpResponse

def get_captcha(request):
    response = requests.get(
        "https://geoportale.cartografia.agenziaentrate.gov.it/age-inspire/srv/ita/Captcha?type=image&lang=it"
    )
    session_id = response.cookies.get("JSESSIONID")
    request.session["CAPTCHA"] = session_id
    content_type = response.headers["content-type"]
    return HttpResponse(response.content, content_type=content_type)

When running the application locally, the API call is executed successfully. However, when running on an Aruba server, it results in a timeout. Here are the steps I've taken to try to resolve this issue, without success:

  • Downgraded OpenSSL to the same version used locally (1.1.1n)
  • Disabled the firewall
  • Changed DNS servers for domain resolution
  • Downgraded the Python version

Below is the result of traceroute from the server:

traceroute to geoportale.cartografia.agenziaentrate.gov.it (217.175.52.194), 30 hops 

max, 60 byte packets
 1  host2-224-110-95.serverdedicati.aruba.it (95.110.224.2)  0.702 ms  0.744 ms  0.824 ms
 2  cr2-te0-0-0-2.it2.aruba.it (62.149.185.196)  0.865 ms  0.919 ms *
 3  * * *
 4  * * *
 5  * * *
 6  * 93-57-68-2.ip163.fastwebnet.it (93.57.68.2)  10.095 ms  10.516 ms
 7  81-208-111-134.ip.fastwebnet.it (81.208.111.134)  10.482 ms  10.370 ms  10.536 ms
 8  * * *
 9  * * *
10  * * *
11  * * *
12  * * *
13  * * *
14  * * *
15  * * *
16  * * *
17  * * *
18  * * *
19  * * *
20  * * *
21  * * *
22  * * *
23  * * *
24  * * *
25  * * *
26  * * *
27  * * *
28  * * *
29  * * *
30  * * *

And here is the output of nslookup from the server:

Server:     127.0.0.53
Address:    127.0.0.53#53

Non-authoritative answer:
Name:   geoportale.cartografia.agenziaentrate.gov.it
Address: 217.175.52.194

These are the details from Chrome inspector for the call made from the server (which fails):

Request URL:    https://beta.service.com/captcha/
Request Method:    GET
Status Code:    500 Internal Server Error
Remote Address:    95.110.228.4:443
Referrer Policy:    same-origin
Connection:    keep-alive
Content-Length:    152853
Content-Type:    text/html; charset=utf-8
Cross-Origin-Opener-Policy:    same-origin
Date:    Tue, 02 Jul 2024 08:39:55 GMT
Referrer-Policy:    same-origin
Server:    nginx
Strict-Transport-Security:    max-age=31536000; includeSubDomains
Vary:    Cookie
X-Content-Type-Options:    nosniff
X-Frame-Options:    DENY
Accept:    */*
Accept-Encoding:    gzip, deflate, br, zstd
Accept-Language:    it-IT,it;q=0.9,en-US;q=0.8,en;q=0.7
Cache-Control:    no-cache
Connection:    keep-alive
Cookie:    _fbp=fb.1.1712064669028.980891575; _ga=GA1.3.585575725.1712064668; _gid=GA1.2.894542501.1719830766; csrftoken=us75UYbPCtVM8DTA0ZhQPzC9ON5Jc3qZ; sessionid=z287mdm63vq9j1p0uxwvf69ieykput00; _gid=GA1.3.894542501.1719830766; _ga=GA1.1.585575725.1712064668; _ga_314551799=GS1.1.1719909450.504.1.1719909452.0.0.0; _ga_52G663NH12=GS1.1.1719909450.176.1.1719909452.58.0.0; _gat_UA-67329675-1=1; _gcl_au=1.1.471068170.1719846195.1018237849.1719909461.1719909460
Host:    beta.service.com
Pragma:    no-cache
Referer:    https://beta.service.com/
Sec-Ch-Ua:    "Not/A)Brand";v="8", "Chromium";v="126", "Google Chrome";v="126"
Sec-Ch-Ua-Mobile:    ?0
Sec-Ch-Ua-Platform:    "Linux"
Sec-Fetch-Dest:    empty
Sec-Fetch-Mode:    cors
Sec-Fetch-Site:    same-origin
User-Agent:    Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36

And these are the details from the local environment (which succeeds):

Request URL:    http://localhost:8000/captcha/
Request Method:    GET
Status Code:    200 OK
Remote Address:    127.0.0.1:8000
Referrer Policy:    same-origin
Content-Length:    19823
Content-Type:    image/jpeg
Cross-Origin-Opener-Policy:    same-origin
Date:    Tue, 02 Jul 2024 10:15:21 GMT
Referrer-Policy:    same-origin
Server:    WSGIServer/0.2 CPython/3.11.9
Set-Cookie:    sessionid=q57cn8cmh1961ghhhu6ywerflojq1f4l; expires=Tue, 16 Jul 2024 10:15:21 GMT; HttpOnly; Max-Age=1209600; Path=/; SameSite=Lax
Vary:    Cookie
X-Content-Type-Options:    nosniff
X-Frame-Options:    DENY
Accept:    */*
Accept-Encoding:    gzip, deflate, br, zstd
Accept-Language:    it-IT,it;q=0.9,en-US;q=0.8,en;q=0.7
Cache-Control:    no-cache
Connection:    keep-alive
Cookie:    _ga=GA1.1.1117820162.1715856098; _gcl_au=1.1.2110919363.1715856098; _fbp=fb.0.1715856098133.219741871; USENAV=1717774507848.1409993568842083; csrftoken=lLd1jqD3VhFqW2NdQI5RAAQEntxfs476; sessionid=q57cn8cmh1961ghhhu6ywerflojq1f4l; _gid=GA1.1.1504428548.1719909313; _ga_52G663NH12=GS1.1.1719909292.46.1.1719909562.60.0.0; _ga_314551799=GS1.1.1719909292.220.1.1719909562.0.0.0
Host:    localhost:8000
Pragma:    no-cache
Referer:    http://localhost:8000/
Sec-Ch-Ua:    "Not/A)Brand";v="8", "Chromium";v="126", "Google Chrome";v="126"
Sec-Ch-Ua-Mobile:    ?0
Sec-Ch-Ua-Platform:    "Linux"
Sec-Fetch-Dest:    empty
Sec-Fetch-Mode:    cors
Sec-Fetch-Site:    same-origin
User-Agent:    Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36

Additional Information: On other two servers from Aruba the call succeds. Aruba's support team claims that nothing is blocking the call on their network. I would appreciate any insights or suggestions on what might be causing this timeout on the server, since right now I don't know what else I could try and where to look to solve it.

EDIT: adding more info on error and variable values

Error

Request Method: GET
Request URL:    https://beta.service.com/captcha/
Django Version: 4.2.2
Exception Type: ConnectTimeout
Exception Value: HTTPSConnectionPool(host='geoportale.cartografia.agenziaentrate.gov.it', port=443): Max retries exceeded with url: /age-inspire/srv/ita/Captcha?type=image&lang=it (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x7f55bb0a6150>, 'Connection to geoportale.cartografia.agenziaentrate.gov.it timed out. (connect timeout=None)'))

Local variables:

cert: None
chunked: False
conn: <urllib3.connectionpool.HTTPSConnectionPool object at 0x7f5579092fd0>
proxies: OrderedDict()
request: <PreparedRequest [GET]>
self: <requests.adapters.HTTPAdapter object at 0x7f55821c33d0>
stream: False
timeout: Timeout(connect=None, read=None, total=None)
url: '/age-inspire/srv/ita/Captcha?type=image&lang=it'
verify: True
3
  • maybe Aruba blocks access to external portals - to stop using Aruba for spamming or hacking. OR maybe other server doesn't allow for access from Aruba because it expects spammers or hackers. Commented Jul 2, 2024 at 19:20
  • error 500 suggests problem inside your code. Maybe you should logging to write information about every line in your code (and all values in variables.) Commented Jul 2, 2024 at 19:23
  • Thank you for your responses. I have other servers on Aruba from which the endpoint responds correctly in less than a second. I don't believe the issue lies in my code, as CURL, PING, and TRACEROUTE also fail from the CLI. I have updated the original post with the error and the variable values. My main assumption is that the destination server is blocking a range of IPs, and unfortunately, my server's IP falls within that range. But I wonder if there's a way to be sure of that other than contacting the server's support team (I know they won't answer in a reasonable amount of time or at all). Commented Jul 3, 2024 at 7:36

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.