Server Connection Error

337 views
Skip to first unread message

Damilola Osabiya

unread,
Nov 8, 2023, 6:11:13 AM11/8/23
to A gathering place for the Open Rail Data community
I am using python to send post requests to https://hsp-prod.rockshore.net/api/v1/serviceMetrics. This has been working just fine until yesterday. I am now getting a 'ConnectionError'. I am guessing the server is down, but I may be wrong. So, in case I am wrong, can anyone tell me what is going on and how I can fix it? Otherwise, could anyone direct me to the server admin to lodge an official complaint?

I am willing to share my codes if necessary.

Peter Hicks

unread,
Nov 8, 2023, 6:13:21 AM11/8/23
to openrail...@googlegroups.com
Hi Damilola

The HSP URL returns data - https://hsp-prod.rockshore.net/ - so it could be something specific to your code, or something about your Internet connection.  Does that URL work for you from the same service you're using to run your code?

'ConnectionError' sounds like it's Python, and there could be a number of reasons for it.  If you're able to post your code, minus any personal information and/or access tokens, either here on a GitHub Gist (https://gist.github.com/), somebody can look and see if they can replicate the problem.


Peter


On Wed, 8 Nov 2023 at 11:11, Damilola Osabiya <damil...@gmail.com> wrote:
I am using python to send post requests to https://hsp-prod.rockshore.net/api/v1/serviceMetrics. This has been working just fine until yesterday. I am now getting a 'ConnectionError'. I am guessing the server is down, but I may be wrong. So, in case I am wrong, can anyone tell me what is going on and how I can fix it? Otherwise, could anyone direct me to the server admin to lodge an official complaint?

I am willing to share my codes if necessary.

--
You received this message because you are subscribed to the Google Groups "A gathering place for the Open Rail Data community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openraildata-t...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/openraildata-talk/41e6e916-1899-4a01-bca1-bd1937a654f7n%40googlegroups.com.

Damilola Osabiya

unread,
Nov 8, 2023, 6:44:12 AM11/8/23
to A gathering place for the Open Rail Data community
Sure. Here is a bit of my code using Python 3.9.12:

import requests
import json
import base64
import pandas as pd

# Define your API credentials and parameters
api_credentials = ("mye...@mail.com", "mypassword")  # Replace with your actual email and password
headers = {
    "Authorization": "Basic " + base64.b64encode(f"{api_credentials[0]}:{api_credentials[1]}".encode()).decode(),
    "Content-Type": "application/json"
}

# Define the request data in JSON format
request_data = {
    "from_loc": "ABE",
    "to_loc": "ABW",
    "from_time": "0700",
    "to_time": "0800",
    "from_date": "2016-07-01",
    "to_date": "2016-08-01",
    "days": "WEEKDAY"
}

# Make the API request
api_url = "https://hsp-prod.rockshore.net/api/v1/serviceMetrics"
response = requests.post(api_url, headers=headers, json=request_data)


And here is the summary of the error I am receiving:

TimeoutError: [Errno 60] Operation timed out During handling of the above exception, another exception occurred:
NewConnectionError: <urllib3.connection.HTTPSConnection object at 0x7fc85800f7f0>: Failed to establish a new connection: [Errno 60] Operation timed out During handling of the above exception, another exception occurred:
MaxRetryError: HTTPSConnectionPool(host='hsp-prod.rockshore.net', port=443): Max retries exceeded with url: /api/v1/serviceMetrics (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7fc85800f7f0>: Failed to establish a new connection: [Errno 60] Operation timed out')) During handling of the above exception, another exception occurred:
ConnectionError: HTTPSConnectionPool(host='hsp-prod.rockshore.net', port=443): Max retries exceeded with url: /api/v1/serviceMetrics (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7fc85800f7f0>: Failed to establish a new connection: [Errno 60] Operation timed out'))

This code was working fine until yesterday afternoon.
Your help is much appreciated.

Damilola.

Peter Hicks

unread,
Nov 8, 2023, 7:14:05 AM11/8/23
to openrail...@googlegroups.com
It looks like a network issue on your side.  It works fine from here (bog-standard BT Internet connection):

pwh@piccadilly:/tmp% python3 ./test.py
<Response [200]>

If you have 'curl' on the machine you're running the code on, try 'curl https://hsp-prod.rockshore.net/' and see if that's allowed.  Assuming it's a Linux (or variant) machine, you should get some HTML back.

If you're running on a Windows machine, check that you don't have local firewall software that may be blocking outbound HTTPS connections from Python.  If you're in a commercial environment, check with your IT department - they may require that you use an HTTP proxy for outbound connections.

Finally, it's possible CACI may have blocked your access to the HSP API if you've been making numerous failed connection attempts in the past.  To check this, try running your script from a machine which accesses the Internet via a different IP address to your current one.


Peter


Damilola Osabiya

unread,
Nov 8, 2023, 7:51:11 AM11/8/23
to A gathering place for the Open Rail Data community
Thank you, Peter. 

I can confirm that the problem is with the network connection where I work. I connected to a different network and the code ran just fine.

Thank you for your help.
Reply all
Reply to author
Forward
0 new messages