PHP在空闲和数据库连接后没有响应

PHP在空闲和数据库连接后没有响应

问题描述:

This problem is driving me mental, have spent many hours already on it.

We are developing a PHP based front-end for a MS SQL database, via a odbc connector. We have ran in to a bug where if you open a page which connects to the database, and then leave it for about 2 minutes, and refresh the page. PHP Will timeout on the refresh. It will not timeout if you refresh within say 30 seconds. It will not do this if you are not connecting to the database. odbc_close is called at the end of each page.

I have tried :

1.  The ODBC Driver 11 for SQL Server
2.  SQL Server Native Client 11.0 Driver/odbc connector  
3.  Installing and using the MSSQL method. Same result.
4.  Changing odbc_close to odbc_close_all on each page.
5.  Using apache 2.2

Running IIS7 on Windows Server 2008R2 with MSSQL Server 2005, PHP 5.4.15

Example Code Test db code :

for($i = 0; $i < 50; $i++)
{
echo"$i <br>";
}

echo"<hr>";
//Sets Password/Username etc.
$conn = odbc_connect("JobTrackTesting","MyUserName","MyPassword");  

$Getsomething = odbc_exec($conn,"SELECT * FROM JobNumber");
while(odbc_fetch_row($Getsomething))
{
    echo odbc_result($Getsomething,JobNumber)."<br>";
}
echo odbc_errormsg();

odbc_close($conn);   

Ended up being a conflict with OpenVPN, Routing the traffic through the wrong subnet.