Skip to content

Timeout error when passing through proxy #517

@atsju

Description

@atsju

Expected Behavior

When trying to connect to database while beeing on a proxy network, a timeout error occurs (WinError 10060). From what I have seen in the source code, PyMySql is not written to be used with proxy. So this seems to be an enhancement request.

Possible Solution

PyMySQL should either take environment variables like http(s)_proxy or have an option in connect method to configure the proxy.

Executable script to reproduce (for bugs)

code:

import pymysql.cursors

# Connect to the database
connection = pymysql.connect(host='localhost',
                             user='user',
                             password='passwd',
                             db='db',
                             charset='utf8mb4',
                             cursorclass=pymysql.cursors.DictCursor)
# connect already failed here (error 10060)
connection.close()

Tracebacks (for bugs)

Traceback (most recent call last):
  File "C:\Python34\lib\site-packages\pymysql-0.7.9-py3.4.egg\pymysql\connections.py", line 890, in connect
    (self.host, self.port), self.connect_timeout)
  File "C:\Python34\lib\socket.py", line 509, in create_connection
    raise err
  File "C:\Python34\lib\socket.py", line 500, in create_connection
    sock.connect(sa)
TimeoutError: [WinError 10060] Une tentative de connexion a échoué car le parti connecté n’a pas répondu convenablement au-delà d’une certaine durée ou une connexion établie a échoué car l’hôte de connexion n’a pas répondu

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "myScript.py", line 4, in <module>
    db = pymysql.connect("aServer.com", "user", "pass", "database" )
  File "C:\Python34\lib\site-packages\pymysql-0.7.9-py3.4.egg\pymysql\__init__.py", line 90, in Connect
    return Connection(*args, **kwargs)
  File "C:\Python34\lib\site-packages\pymysql-0.7.9-py3.4.egg\pymysql\connections.py", line 688, in __init__
    self.connect()
  File "C:\Python34\lib\site-packages\pymysql-0.7.9-py3.4.egg\pymysql\connections.py", line 937, in connect
    raise exc
pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'aServer.com' ([WinError 10060] Une tentative de connexion a échoué car le parti connecté n’a pas répondu convenablement au-delà d’une certaine durée ou une connexion établie a échoué car l’hôte de connexion n’a pas répondu)")

Context

Your Environment

  • Operating System and version:Windows 7, proxy configured with PAC file
  • Python version and build (cygwin, python.org, homebrew, pyenv, Linux distribution's package, PyPy etc...) Python 3.4.2
  • PyMySQL Version used: 0.7.9
  • my.cnf if possible. If you don't have it, related system variables like connection encoding.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions