Giter Club home page Giter Club logo

Comments (6)

jacobsvante avatar jacobsvante commented on June 16, 2024

Hi dkleehammer,

First of all, thanks for an awesome project.

I'm having this problem with both 3.0.6 and the latest beta (3.0.7-beta03). If I set an incorrect server name in the connect string it tries to connect forever even though I've added the timeout flag to the connect method. Keyboard interrupts don't work until maybe a minute in or so.

I'm on Mac OS X 10.8.2 (64-bit) and the database I'm trying to connect to is a SQL Server 2008 R2 x64 (10.50.1617.0).

I can see that you closed this ticket. Was this fixed?

from pyodbc.

dkleehammer avatar dkleehammer commented on June 16, 2024

jmagnusson,

Actually, this project is ran by my brother, mkleehammer, but I'm sure he'll check this one. :D

I was incorrect about the keywords in the connection string. The timeout is soley used for query timeouts. We are investigating why the odbc connection timeout isn't being handled properly. We believe we are on the right track and will update pyodbc with the fix as quickly as possible.

dk

from pyodbc.

ltoshea avatar ltoshea commented on June 16, 2024

Did this ever get fixed?
Currently I have a firewall blocking outbound database connections. I've only just found this out after some debugging - unfortunately the timeout keyword seems to be being ignored and it hangs forever. On non firewalled host it works fine but I need me application to raise an error not just hang.

CONN_STRING = 'DSN={};DATABASE={};UID={};PWD={}'.format(SERVER,DATABASE,UID,PWD) conn = pyodbc.connect(CONN_STRING,timeout=15)

from pyodbc.

 avatar commented on June 16, 2024

Is this issue fixed?

from pyodbc.

ltoshea avatar ltoshea commented on June 16, 2024

I don't believe so

On Wed, 6 Apr 2016, 09:13 Sreejith Kesavan, [email protected]
wrote:

Is this issue fixed?


You are receiving this because you commented.
Reply to this email directly or view it on GitHub
#11 (comment)

Sent from Android

from pyodbc.

JavaScriptDude avatar JavaScriptDude commented on June 16, 2024

Just discovered this same issue on Windows Server 2019 using ODBC Driver 17 for SQL Server. I have a canary that is checking health of services using pyodbc and hit was hanging on this when port is not responding.

Work around is to do a port scan of 1433 before trying to connect.

Here is a helper for scanning ports:

# (bPortOpen, iErrno) = scanPort('<ip>', <port>)
def scanPort(host:str, port:int, timeout:int=4) -> tuple(bool, int):
    errno = 0 # see TCP socket error codes https://gist.github.com/gabrielfalcao/4216897
    sock = None
    try:
        sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        sock.settimeout(timeout)
        errno = sock.connect_ex((host, port))
    except socket.timeout:
        errno=-1
    except socket.gaierror:
        errno=112
    except socket.error:
        errno=111
    try:
        sock.close()
    except:
        None
    return ((errno == 0), errno)

from pyodbc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.