msphpsql: Sporadic: SQLSTATE[HYT00]: [unixODBC][Microsoft][ODBC Driver 17 for SQL Server]Login timeout expired
Problem description
I am aware of issue #679, however, that seems to relate to a persistent login timeout, whereas my login timeouts issue is only sporadic. Maybe 1 in 5 queries will result in the error present in the title, additionally, query results are often extremely slow; which makes even something like development an unliveable environment.
I’m running Laravel 5.6 on a Homestead instance with a full provisioning configuration provided below. My post-provision file which should give an idea of the setup involved.
# https://docs.microsoft.com/en-us/sql/linux/quickstart-install-connect-ubuntu
# https://askubuntu.com/questions/930712/installation-problems-with-ms-sql-server-for-linux/945957
# Include bash configuration variables
. /home/vagrant/code/configuration.sh
# Add
curl https://packages.microsoft.com/keys/microsoft.asc --silent | sudo apt-key add -
sudo add-apt-repository "$(curl https://packages.microsoft.com/config/ubuntu/16.04/mssql-server-2017.list)"
sudo apt-get update -q
# Downgrade OpenSSL to 1.0.2 for MSSQL
sudo apt-get install -o Dpkg::Options::="--force-confnew" openssl=1.0.2g-1ubuntu4.10 -y --allow-downgrades
sudo apt-get install mssql-server -y
# Setup MSSQL
sudo MSSQL_PID=Express ACCEPT_EULA=Y MSSQL_SA_PASSWORD="$mssql_sa_pw" /opt/mssql/bin/mssql-conf -n setup
# Add MSSQL tooling
sudo add-apt-repository "$(curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list)"
sudo ACCEPT_EULA=Y apt-get install -y mssql-tools unixodbc-dev
# Add MSSQL tooling to our path
sudo ln -s /opt/mssql-tools/bin/* /usr/local/bin
# Create our database
sqlcmd -S localhost -U SA -P "$mssql_sa_pw" -Q "CREATE DATABASE $mssql_db_database"
# Follow configuration for PHP (from step 3, as above commands covered prior steps regardless)
# https://github.com/Microsoft/msphpsql
sudo pear config-set php_ini `php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||"` system
# Install SQL Server PECL extensions
sudo pecl install sqlsrv-5.2.0RC1
sudo pecl install pdo_sqlsrv-5.2.0RC1
# Include in configuration
echo "extension=sqlsrv.so" | sudo tee --append /etc/php/7.2/fpm/php.ini
echo "extension=pdo_sqlsrv.so" | sudo tee --append /etc/php/7.2/fpm/php.ini
Driver version or file name
Not sure how to find this. Tell me how and I will add.
SQL Server version
Not sure how to find this. Tell me how and I will add.
Client operating system
Ubuntu 16.04.4 LTS (GNU/Linux 4.4.0-116-generic x86_64)
PHP version
PHP 7.2 / 5.2.0RC1 pdo-sqlsrv, 5.2.0 sqlsrv.
Microsoft ODBC Driver version
ODBC Driver 17 for SQL Server / unixodbc / msodbcsql17 (version 17.0.1.1-1)
Expected behavior and actual behaviour
No login timeouts. Instead, I get sporadic login timeouts as described above.
Repro code
Sporadic, but even simple queries made by Eloquent such as SELECT * FROM items`` can result in a failure. I don’t use the sqlcmd command line tool all that often, so I cannot determine if this is a PDO driver issue.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 28 (13 by maintainers)
@luiz-luxfacta Could you clarify, does the problem happen intermittently, or does it happen whenever you try to connect? Do you get the same behaviour when connecting with sqlcmd?
@ChrisBachi You are trying to connect to a named instance, so you need to specify the port number. Try
1433 is the default port, replace it if appropriate for your configuration. For more information, see issues #442 and #470, and this page.
@yitam @david-puglielli We are still unable to find out what is happening but we were able to run the same tests on our application UAT environment (which is outside our local network) and the issue isn’t happening in there. We will continue to monitor but as you said the issue is problably related to some kind of network or instance error. Thank you for trying to help us figure this out.
Thanks for you feedback @yitam, we were already investigating with out infraestructure team. We were not able to find any network related issues but we will continue to do some digging and I’ll let you know if we find anything out.