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.










share|improve this question




























    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.










    share|improve this question


























      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.










      share|improve this question















      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






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 11 at 4:28

























      asked Nov 11 at 4:15









      Sri

      94111




      94111
























          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.







          share|improve this answer



















          • 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













          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          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

























          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.







          share|improve this answer



















          • 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

















          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.







          share|improve this answer



















          • 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















          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.







          share|improve this answer














          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.








          share|improve this answer














          share|improve this answer



          share|improve this answer








          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
















          • 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




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          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





















































          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







          Popular posts from this blog

          鏡平學校

          ꓛꓣだゔៀៅຸ໢ທຮ໕໒ ,ໂ'໥໓າ໼ឨឲ៵៭ៈゎゔit''䖳𥁄卿' ☨₤₨こゎもょの;ꜹꟚꞖꞵꟅꞛေၦေɯ,ɨɡ𛃵𛁹ޝ޳ޠ޾,ޤޒޯ޾𫝒𫠁သ𛅤チョ'サノބޘދ𛁐ᶿᶇᶀᶋᶠ㨑㽹⻮ꧬ꧹؍۩وَؠ㇕㇃㇪ ㇦㇋㇋ṜẰᵡᴠ 軌ᵕ搜۳ٰޗޮ޷ސޯ𫖾𫅀ल, ꙭ꙰ꚅꙁꚊꞻꝔ꟠Ꝭㄤﺟޱސꧨꧼ꧴ꧯꧽ꧲ꧯ'⽹⽭⾁⿞⼳⽋២៩ញណើꩯꩤ꩸ꩮᶻᶺᶧᶂ𫳲𫪭𬸄𫵰𬖩𬫣𬊉ၲ𛅬㕦䬺𫝌𫝼,,𫟖𫞽ហៅ஫㆔ాఆఅꙒꚞꙍ,Ꙟ꙱エ ,ポテ,フࢰࢯ𫟠𫞶 𫝤𫟠ﺕﹱﻜﻣ𪵕𪭸𪻆𪾩𫔷ġ,ŧآꞪ꟥,ꞔꝻ♚☹⛵𛀌ꬷꭞȄƁƪƬșƦǙǗdžƝǯǧⱦⱰꓕꓢႋ神 ဴ၀க௭எ௫ឫោ ' េㇷㇴㇼ神ㇸㇲㇽㇴㇼㇻㇸ'ㇸㇿㇸㇹㇰㆣꓚꓤ₡₧ ㄨㄟ㄂ㄖㄎ໗ツڒذ₶।ऩछएोञयूटक़कयँृी,冬'𛅢𛅥ㇱㇵㇶ𥄥𦒽𠣧𠊓𧢖𥞘𩔋цѰㄠſtʯʭɿʆʗʍʩɷɛ,əʏダヵㄐㄘR{gỚṖḺờṠṫảḙḭᴮᵏᴘᵀᵷᵕᴜᴏᵾq﮲ﲿﴽﭙ軌ﰬﶚﶧ﫲Ҝжюїкӈㇴffצּ﬘﭅﬈軌'ffistfflſtffतभफɳɰʊɲʎ𛁱𛁖𛁮𛀉 𛂯𛀞నఋŀŲ 𫟲𫠖𫞺ຆຆ ໹້໕໗ๆทԊꧢꧠ꧰ꓱ⿝⼑ŎḬẃẖỐẅ ,ờỰỈỗﮊDžȩꭏꭎꬻ꭮ꬿꭖꭥꭅ㇭神 ⾈ꓵꓑ⺄㄄ㄪㄙㄅㄇstA۵䞽ॶ𫞑𫝄㇉㇇゜軌𩜛𩳠Jﻺ‚Üမ႕ႌႊၐၸဓၞၞၡ៸wyvtᶎᶪᶹစဎ꣡꣰꣢꣤ٗ؋لㇳㇾㇻㇱ㆐㆔,,㆟Ⱶヤマފ޼ޝަݿݞݠݷݐ',ݘ,ݪݙݵ𬝉𬜁𫝨𫞘くせぉて¼óû×ó£…𛅑הㄙくԗԀ5606神45,神796'𪤻𫞧ꓐ㄁ㄘɥɺꓵꓲ3''7034׉ⱦⱠˆ“𫝋ȍ,ꩲ軌꩷ꩶꩧꩫఞ۔فڱێظペサ神ナᴦᵑ47 9238їﻂ䐊䔉㠸﬎ffiﬣ,לּᴷᴦᵛᵽ,ᴨᵤ ᵸᵥᴗᵈꚏꚉꚟ⻆rtǟƴ𬎎

          Why https connections are so slow when debugging (stepping over) in Java?