PHP Fatal error: Uncaught HY000 : “Adaptive Server connection timed out”
up vote
0
down vote
favorite
I am running a PHP script to connect to MsSQL and execute a long running stored procedure. That procedure expects an ID which I pass in through this script. I loop over all the ID array and call this procedure. However for some IDs this procedure takes lot of time to run and times out. I set the ATTR_TIMEOUT PDO property to 600s. I have all the PDO statements inside a try catch block. Still, I get this uncaught exception. Here is my sample code: (Please ignore the new_statement params. I used dummies here. Its a valid one and runs fine)
try {
$statement = PDO::new_statement('DB', $sql, 0, false, false, [PDO::ATTR_TIMEOUT => 600]);
$this->execute($statement);
} catch (Exception $e) {
$logger->error("Error for ID: " . $id);
}
This works perfectly for most of the IDs. It fails for some long running IDs. If there is a TIMEOUT issue with executing the query, I would expect the error to be logged. However I see this exception:
PHP Fatal error: Uncaught HY000
["HY000",20003,"Adaptive Server connection timed out [20003] (severity 6)
Could someone please help me with this.
php sql-server pdo
add a comment |
up vote
0
down vote
favorite
I am running a PHP script to connect to MsSQL and execute a long running stored procedure. That procedure expects an ID which I pass in through this script. I loop over all the ID array and call this procedure. However for some IDs this procedure takes lot of time to run and times out. I set the ATTR_TIMEOUT PDO property to 600s. I have all the PDO statements inside a try catch block. Still, I get this uncaught exception. Here is my sample code: (Please ignore the new_statement params. I used dummies here. Its a valid one and runs fine)
try {
$statement = PDO::new_statement('DB', $sql, 0, false, false, [PDO::ATTR_TIMEOUT => 600]);
$this->execute($statement);
} catch (Exception $e) {
$logger->error("Error for ID: " . $id);
}
This works perfectly for most of the IDs. It fails for some long running IDs. If there is a TIMEOUT issue with executing the query, I would expect the error to be logged. However I see this exception:
PHP Fatal error: Uncaught HY000
["HY000",20003,"Adaptive Server connection timed out [20003] (severity 6)
Could someone please help me with this.
php sql-server pdo
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I am running a PHP script to connect to MsSQL and execute a long running stored procedure. That procedure expects an ID which I pass in through this script. I loop over all the ID array and call this procedure. However for some IDs this procedure takes lot of time to run and times out. I set the ATTR_TIMEOUT PDO property to 600s. I have all the PDO statements inside a try catch block. Still, I get this uncaught exception. Here is my sample code: (Please ignore the new_statement params. I used dummies here. Its a valid one and runs fine)
try {
$statement = PDO::new_statement('DB', $sql, 0, false, false, [PDO::ATTR_TIMEOUT => 600]);
$this->execute($statement);
} catch (Exception $e) {
$logger->error("Error for ID: " . $id);
}
This works perfectly for most of the IDs. It fails for some long running IDs. If there is a TIMEOUT issue with executing the query, I would expect the error to be logged. However I see this exception:
PHP Fatal error: Uncaught HY000
["HY000",20003,"Adaptive Server connection timed out [20003] (severity 6)
Could someone please help me with this.
php sql-server pdo
I am running a PHP script to connect to MsSQL and execute a long running stored procedure. That procedure expects an ID which I pass in through this script. I loop over all the ID array and call this procedure. However for some IDs this procedure takes lot of time to run and times out. I set the ATTR_TIMEOUT PDO property to 600s. I have all the PDO statements inside a try catch block. Still, I get this uncaught exception. Here is my sample code: (Please ignore the new_statement params. I used dummies here. Its a valid one and runs fine)
try {
$statement = PDO::new_statement('DB', $sql, 0, false, false, [PDO::ATTR_TIMEOUT => 600]);
$this->execute($statement);
} catch (Exception $e) {
$logger->error("Error for ID: " . $id);
}
This works perfectly for most of the IDs. It fails for some long running IDs. If there is a TIMEOUT issue with executing the query, I would expect the error to be logged. However I see this exception:
PHP Fatal error: Uncaught HY000
["HY000",20003,"Adaptive Server connection timed out [20003] (severity 6)
Could someone please help me with this.
php sql-server pdo
php sql-server pdo
edited Nov 11 at 4:28
asked Nov 11 at 4:15
Sri
94111
94111
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
Pass the options to the PDO constructor:
$pdo = new PDO(
"mysql:host=$host;dbname=$dbname",
$username,
$password,
array(
PDO::ATTR_TIMEOUT => "(seconds)",
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
)
);
if that doesn't help, you can try to set connect_timeout manually in php.ini
or use ini_set()
mysql.connect_timeout = "(seconds)"
If the driver uses sockets for the basic connection, and to set timeouts, you need to use the socket (stream) timeout function
ini_set("default_socket_timeout", "(seconds)");
You should also know that
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.
1
Can you explain why you think that this solves the problem? As far as I see, the OP does not use MySQL after all
– Nico Haase
Nov 11 at 13:31
This does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker. - From Review
– tiagoperes
Nov 11 at 16:51
Thank you I will take note.
– Yaroslaw
Nov 11 at 17:24
Yeah, the timeout works. In fact it waits for 10 minutes and fails. So not sure how to catch this error.
– Sri
Nov 11 at 17:27
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
Pass the options to the PDO constructor:
$pdo = new PDO(
"mysql:host=$host;dbname=$dbname",
$username,
$password,
array(
PDO::ATTR_TIMEOUT => "(seconds)",
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
)
);
if that doesn't help, you can try to set connect_timeout manually in php.ini
or use ini_set()
mysql.connect_timeout = "(seconds)"
If the driver uses sockets for the basic connection, and to set timeouts, you need to use the socket (stream) timeout function
ini_set("default_socket_timeout", "(seconds)");
You should also know that
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.
1
Can you explain why you think that this solves the problem? As far as I see, the OP does not use MySQL after all
– Nico Haase
Nov 11 at 13:31
This does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker. - From Review
– tiagoperes
Nov 11 at 16:51
Thank you I will take note.
– Yaroslaw
Nov 11 at 17:24
Yeah, the timeout works. In fact it waits for 10 minutes and fails. So not sure how to catch this error.
– Sri
Nov 11 at 17:27
add a comment |
up vote
0
down vote
Pass the options to the PDO constructor:
$pdo = new PDO(
"mysql:host=$host;dbname=$dbname",
$username,
$password,
array(
PDO::ATTR_TIMEOUT => "(seconds)",
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
)
);
if that doesn't help, you can try to set connect_timeout manually in php.ini
or use ini_set()
mysql.connect_timeout = "(seconds)"
If the driver uses sockets for the basic connection, and to set timeouts, you need to use the socket (stream) timeout function
ini_set("default_socket_timeout", "(seconds)");
You should also know that
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.
1
Can you explain why you think that this solves the problem? As far as I see, the OP does not use MySQL after all
– Nico Haase
Nov 11 at 13:31
This does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker. - From Review
– tiagoperes
Nov 11 at 16:51
Thank you I will take note.
– Yaroslaw
Nov 11 at 17:24
Yeah, the timeout works. In fact it waits for 10 minutes and fails. So not sure how to catch this error.
– Sri
Nov 11 at 17:27
add a comment |
up vote
0
down vote
up vote
0
down vote
Pass the options to the PDO constructor:
$pdo = new PDO(
"mysql:host=$host;dbname=$dbname",
$username,
$password,
array(
PDO::ATTR_TIMEOUT => "(seconds)",
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
)
);
if that doesn't help, you can try to set connect_timeout manually in php.ini
or use ini_set()
mysql.connect_timeout = "(seconds)"
If the driver uses sockets for the basic connection, and to set timeouts, you need to use the socket (stream) timeout function
ini_set("default_socket_timeout", "(seconds)");
You should also know that
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.
Pass the options to the PDO constructor:
$pdo = new PDO(
"mysql:host=$host;dbname=$dbname",
$username,
$password,
array(
PDO::ATTR_TIMEOUT => "(seconds)",
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
)
);
if that doesn't help, you can try to set connect_timeout manually in php.ini
or use ini_set()
mysql.connect_timeout = "(seconds)"
If the driver uses sockets for the basic connection, and to set timeouts, you need to use the socket (stream) timeout function
ini_set("default_socket_timeout", "(seconds)");
You should also know that
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.
edited Nov 11 at 17:21
answered Nov 11 at 8:20
Yaroslaw
684
684
1
Can you explain why you think that this solves the problem? As far as I see, the OP does not use MySQL after all
– Nico Haase
Nov 11 at 13:31
This does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker. - From Review
– tiagoperes
Nov 11 at 16:51
Thank you I will take note.
– Yaroslaw
Nov 11 at 17:24
Yeah, the timeout works. In fact it waits for 10 minutes and fails. So not sure how to catch this error.
– Sri
Nov 11 at 17:27
add a comment |
1
Can you explain why you think that this solves the problem? As far as I see, the OP does not use MySQL after all
– Nico Haase
Nov 11 at 13:31
This does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker. - From Review
– tiagoperes
Nov 11 at 16:51
Thank you I will take note.
– Yaroslaw
Nov 11 at 17:24
Yeah, the timeout works. In fact it waits for 10 minutes and fails. So not sure how to catch this error.
– Sri
Nov 11 at 17:27
1
1
Can you explain why you think that this solves the problem? As far as I see, the OP does not use MySQL after all
– Nico Haase
Nov 11 at 13:31
Can you explain why you think that this solves the problem? As far as I see, the OP does not use MySQL after all
– Nico Haase
Nov 11 at 13:31
This does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker. - From Review
– tiagoperes
Nov 11 at 16:51
This does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker. - From Review
– tiagoperes
Nov 11 at 16:51
Thank you I will take note.
– Yaroslaw
Nov 11 at 17:24
Thank you I will take note.
– Yaroslaw
Nov 11 at 17:24
Yeah, the timeout works. In fact it waits for 10 minutes and fails. So not sure how to catch this error.
– Sri
Nov 11 at 17:27
Yeah, the timeout works. In fact it waits for 10 minutes and fails. So not sure how to catch this error.
– Sri
Nov 11 at 17:27
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53245785%2fphp-fatal-error-uncaught-hy000-adaptive-server-connection-timed-out%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown