IBM i Access ODBC and PDO/ODBC drivers do not support a Connection Timeout

Issue #164 closed
Chris Sears created an issue

I am using the IBM i Access ODBC driver with PHP, and it does not have an option for Connection Timeout. If the server DSN is temporarily unreachable, the connection will wait to timeout until the PHP max_execution_time is reached. It would be nice if the driver supports a connection keyword to optionally set a number of seconds to wait for the connection to timeout, and return a connection error.

Current Connection String Keywords:

https://www.ibm.com/docs/en/i/7.3?topic=details-connection-string-keywords

Additionally the PDO/ODBC driver also does not currently support the PDO:ATTR_TIMEOUT attribute.

https://www.php.net/manual/en/pdo.setattribute.php

PDO::ATTR_TIMEOUT: Specifies the timeout duration in seconds. Not all drivers support this option, and its meaning may differ from driver to driver. For example, sqlite will wait for up to this time value before giving up on obtaining an writable lock, but other drivers may interpret this as a connect or a read timeout interval. Requires int.

There is currently a bug submitted, but appears no activity has happened:

PDO/ODBC driver doesn't respect PDO::ATTR_TIMEOUT option: https://bugs.php.net/bug.php?id=45287

Is it possible to support a connection timeout using PDO/ODBC on the IBMi?

There are manual alternatives to use PHP fsockopen with the timeout parameter to check if a host is reachable, and then proceed to connect with$dbh = new PDO(… but hoping for a more standard solution.

Comments (4)

  1. Kevin Adler

    This definitely seems like a reasonable request, just not in the correct place.

    For PDO::ODBC, you’ll need to work with the upstream PHP community or your PHP vendor to add that support. For ODBC support of a new connection option, you’ll need to open an RFE.

  2. Log in to comment