Search code examples
python-3.xhttpsfilemaker

How do i fix HTTPSConnectionPool - Read Timed Out Error when connecting to database server


I am trying to connect to a FileMaker Databse server via python script, and my code was working before but has suddenly stopped, and i didnt make any changes to the portion of code that no longer works. I am encountering the following error:

Request error: HTTPSConnectionPool(host='**.**.*.*', port=443): Read timed out. (read timeout=30)

I have taken out the code that creates the server instance and connects/logs in, and then logs out without making any changes in the database, and i am still recieving the same error. However, i can connect to the filemaker server and database via the FileMaker applicaiton with no issues, and i can connect to the server using Telnet commands. I am on windows 10 and writing the code in PyCharm CE. I have reinstalled PyCharm, created a new virtual environment, and tried reinstalling the fmrest module, as well as using older versions. I have also increased the timeout time to give more time to login, which hasnt worked. I'm basically stumped on why i can no longer log in via the script, when it has been working perfectly in testing for the past couple weeks. My code is below.

import fmrest
from fmrest.exceptions import FileMakerError
from fmrest.exceptions import RequestException
import sys
import requests

# connect to the FileMaker Server
requests.packages.urllib3.disable_warnings()
fmrest.utils.TIMEOUT = 30
try:
    fms = fmrest.Server('https://**.**.*.*',
                        user = '***',
                        password = '******',
                        database = 'Hangtag Order Management',
                        layout = 'OrderAdmin',
                        verify_ssl = False)
except ValueError as err:
    print('Failed to connect to server. Please check server credentials and status and try again\n\n' + str(err))
    sys.exit()

print(fms)
print('Attempting to connect to FileMaker Server...')

try:
    fms.login()
    print('Login Successful\n')
except FileMakerError as err:
    print(err)
    sys.exit()
except RequestException as err:
    print('There was an error connecting to the server, the request timed out\n\n' + str(err))
    sys.exit()

fms.logout()

This should successfully login to the database, print 'login successful' and log out. Calling print(fms) returns

<Server logged_in=False database=Hangtag Order Management layout=OrderAdmin>

but i receive the connection error upon the login attempt. I am assuming the error is server side, but i dont know enough about servers to accurately trouble shoot. Could the server have blacklisted my IP for making so many login attempts during my testing? and if so where would i undo that/prevent it from happening again?


Solution

  • A couple of server reboots fixed the error, not really sure of the ultimate cause.