Presto Query through ELB error “The plain HTTP request was sent to HTTPS”












0














When use an AWS ELB (Elastic Load Balancer) with HTTPS listener that forward the request to the presto cluster (0.193) behind that runs on HTTP, Java client that uses presto-jdbc (0.213) fails to execute select query due to "plain HTTP request was sent to HTTPS port" error.



Exception in thread "main" java.sql.SQLException: Error executing query
at com.facebook.presto.jdbc.PrestoStatement.internalExecute(PrestoStatement.java:274)
at com.facebook.presto.jdbc.PrestoStatement.execute(PrestoStatement.java:227)
at com.facebook.presto.jdbc.PrestoStatement.executeQuery(PrestoStatement.java:76)
at com.DpTool.executeJdbcQuerySsl(DpTool.java:332)
at com.DpTool.prestoJdbcSsl(DpTool.java:315)
at com.DpTool.main(DpTool.java:520)
Caused by: java.lang.RuntimeException: Error fetching next at http://cluster-elb.mydomain:8443/v1/statement/20181120_215602_00038_57ryf/1 returned an invalid response: JsonResponse{statusCode=400, statusMessage=Bad Request, headers={connection=[close], content-length=[236], content-type=[text/html], date=[Tue, 20 Nov 2018 21:56:02 GMT], server=[awselb/2.0]}, hasValue=false} [Error: <html>
<head><title>400 The plain HTTP request was sent to HTTPS port</title></head>
<body bgcolor="white">
<center><h1>400 Bad Request</h1></center>
<center>The plain HTTP request was sent to HTTPS port</center>
</body>
</html>
]
at com.facebook.presto.jdbc.internal.client.StatementClientV1.requestFailedException(StatementClientV1.java:436)
at com.facebook.presto.jdbc.internal.client.StatementClientV1.advance(StatementClientV1.java:383)
at com.facebook.presto.jdbc.PrestoResultSet.getColumns(PrestoResultSet.java:1742)
at com.facebook.presto.jdbc.PrestoResultSet.<init>(PrestoResultSet.java:119)
at com.facebook.presto.jdbc.PrestoStatement.internalExecute(PrestoStatement.java:249)
... 5 more


It appears that StatementClientV1.advance code try to visit "http://cluster-elb.mydomain:8443/..." which is the ELB address except it should be "https" instead of "http" prefix. The same client code works fine when execute query directly to another HTTPS presto cluster (no ELB). Here is the client Java code. url is "cluster-elb.mydomain:8443"



Properties properties = new Properties();
properties.setProperty("SSL", "true");
Connection conn = DriverManager.getConnection(url, properties);
Statement stmt = conn.createStatement();
String query = "select cluster, query_text from mytable where ds='2018-10-20' limit 10";
ResultSet rs = stmt.executeQuery(query);


Why the presto-jdbc client code is confused and how to make the query work?










share|improve this question



























    0














    When use an AWS ELB (Elastic Load Balancer) with HTTPS listener that forward the request to the presto cluster (0.193) behind that runs on HTTP, Java client that uses presto-jdbc (0.213) fails to execute select query due to "plain HTTP request was sent to HTTPS port" error.



    Exception in thread "main" java.sql.SQLException: Error executing query
    at com.facebook.presto.jdbc.PrestoStatement.internalExecute(PrestoStatement.java:274)
    at com.facebook.presto.jdbc.PrestoStatement.execute(PrestoStatement.java:227)
    at com.facebook.presto.jdbc.PrestoStatement.executeQuery(PrestoStatement.java:76)
    at com.DpTool.executeJdbcQuerySsl(DpTool.java:332)
    at com.DpTool.prestoJdbcSsl(DpTool.java:315)
    at com.DpTool.main(DpTool.java:520)
    Caused by: java.lang.RuntimeException: Error fetching next at http://cluster-elb.mydomain:8443/v1/statement/20181120_215602_00038_57ryf/1 returned an invalid response: JsonResponse{statusCode=400, statusMessage=Bad Request, headers={connection=[close], content-length=[236], content-type=[text/html], date=[Tue, 20 Nov 2018 21:56:02 GMT], server=[awselb/2.0]}, hasValue=false} [Error: <html>
    <head><title>400 The plain HTTP request was sent to HTTPS port</title></head>
    <body bgcolor="white">
    <center><h1>400 Bad Request</h1></center>
    <center>The plain HTTP request was sent to HTTPS port</center>
    </body>
    </html>
    ]
    at com.facebook.presto.jdbc.internal.client.StatementClientV1.requestFailedException(StatementClientV1.java:436)
    at com.facebook.presto.jdbc.internal.client.StatementClientV1.advance(StatementClientV1.java:383)
    at com.facebook.presto.jdbc.PrestoResultSet.getColumns(PrestoResultSet.java:1742)
    at com.facebook.presto.jdbc.PrestoResultSet.<init>(PrestoResultSet.java:119)
    at com.facebook.presto.jdbc.PrestoStatement.internalExecute(PrestoStatement.java:249)
    ... 5 more


    It appears that StatementClientV1.advance code try to visit "http://cluster-elb.mydomain:8443/..." which is the ELB address except it should be "https" instead of "http" prefix. The same client code works fine when execute query directly to another HTTPS presto cluster (no ELB). Here is the client Java code. url is "cluster-elb.mydomain:8443"



    Properties properties = new Properties();
    properties.setProperty("SSL", "true");
    Connection conn = DriverManager.getConnection(url, properties);
    Statement stmt = conn.createStatement();
    String query = "select cluster, query_text from mytable where ds='2018-10-20' limit 10";
    ResultSet rs = stmt.executeQuery(query);


    Why the presto-jdbc client code is confused and how to make the query work?










    share|improve this question

























      0












      0








      0







      When use an AWS ELB (Elastic Load Balancer) with HTTPS listener that forward the request to the presto cluster (0.193) behind that runs on HTTP, Java client that uses presto-jdbc (0.213) fails to execute select query due to "plain HTTP request was sent to HTTPS port" error.



      Exception in thread "main" java.sql.SQLException: Error executing query
      at com.facebook.presto.jdbc.PrestoStatement.internalExecute(PrestoStatement.java:274)
      at com.facebook.presto.jdbc.PrestoStatement.execute(PrestoStatement.java:227)
      at com.facebook.presto.jdbc.PrestoStatement.executeQuery(PrestoStatement.java:76)
      at com.DpTool.executeJdbcQuerySsl(DpTool.java:332)
      at com.DpTool.prestoJdbcSsl(DpTool.java:315)
      at com.DpTool.main(DpTool.java:520)
      Caused by: java.lang.RuntimeException: Error fetching next at http://cluster-elb.mydomain:8443/v1/statement/20181120_215602_00038_57ryf/1 returned an invalid response: JsonResponse{statusCode=400, statusMessage=Bad Request, headers={connection=[close], content-length=[236], content-type=[text/html], date=[Tue, 20 Nov 2018 21:56:02 GMT], server=[awselb/2.0]}, hasValue=false} [Error: <html>
      <head><title>400 The plain HTTP request was sent to HTTPS port</title></head>
      <body bgcolor="white">
      <center><h1>400 Bad Request</h1></center>
      <center>The plain HTTP request was sent to HTTPS port</center>
      </body>
      </html>
      ]
      at com.facebook.presto.jdbc.internal.client.StatementClientV1.requestFailedException(StatementClientV1.java:436)
      at com.facebook.presto.jdbc.internal.client.StatementClientV1.advance(StatementClientV1.java:383)
      at com.facebook.presto.jdbc.PrestoResultSet.getColumns(PrestoResultSet.java:1742)
      at com.facebook.presto.jdbc.PrestoResultSet.<init>(PrestoResultSet.java:119)
      at com.facebook.presto.jdbc.PrestoStatement.internalExecute(PrestoStatement.java:249)
      ... 5 more


      It appears that StatementClientV1.advance code try to visit "http://cluster-elb.mydomain:8443/..." which is the ELB address except it should be "https" instead of "http" prefix. The same client code works fine when execute query directly to another HTTPS presto cluster (no ELB). Here is the client Java code. url is "cluster-elb.mydomain:8443"



      Properties properties = new Properties();
      properties.setProperty("SSL", "true");
      Connection conn = DriverManager.getConnection(url, properties);
      Statement stmt = conn.createStatement();
      String query = "select cluster, query_text from mytable where ds='2018-10-20' limit 10";
      ResultSet rs = stmt.executeQuery(query);


      Why the presto-jdbc client code is confused and how to make the query work?










      share|improve this question













      When use an AWS ELB (Elastic Load Balancer) with HTTPS listener that forward the request to the presto cluster (0.193) behind that runs on HTTP, Java client that uses presto-jdbc (0.213) fails to execute select query due to "plain HTTP request was sent to HTTPS port" error.



      Exception in thread "main" java.sql.SQLException: Error executing query
      at com.facebook.presto.jdbc.PrestoStatement.internalExecute(PrestoStatement.java:274)
      at com.facebook.presto.jdbc.PrestoStatement.execute(PrestoStatement.java:227)
      at com.facebook.presto.jdbc.PrestoStatement.executeQuery(PrestoStatement.java:76)
      at com.DpTool.executeJdbcQuerySsl(DpTool.java:332)
      at com.DpTool.prestoJdbcSsl(DpTool.java:315)
      at com.DpTool.main(DpTool.java:520)
      Caused by: java.lang.RuntimeException: Error fetching next at http://cluster-elb.mydomain:8443/v1/statement/20181120_215602_00038_57ryf/1 returned an invalid response: JsonResponse{statusCode=400, statusMessage=Bad Request, headers={connection=[close], content-length=[236], content-type=[text/html], date=[Tue, 20 Nov 2018 21:56:02 GMT], server=[awselb/2.0]}, hasValue=false} [Error: <html>
      <head><title>400 The plain HTTP request was sent to HTTPS port</title></head>
      <body bgcolor="white">
      <center><h1>400 Bad Request</h1></center>
      <center>The plain HTTP request was sent to HTTPS port</center>
      </body>
      </html>
      ]
      at com.facebook.presto.jdbc.internal.client.StatementClientV1.requestFailedException(StatementClientV1.java:436)
      at com.facebook.presto.jdbc.internal.client.StatementClientV1.advance(StatementClientV1.java:383)
      at com.facebook.presto.jdbc.PrestoResultSet.getColumns(PrestoResultSet.java:1742)
      at com.facebook.presto.jdbc.PrestoResultSet.<init>(PrestoResultSet.java:119)
      at com.facebook.presto.jdbc.PrestoStatement.internalExecute(PrestoStatement.java:249)
      ... 5 more


      It appears that StatementClientV1.advance code try to visit "http://cluster-elb.mydomain:8443/..." which is the ELB address except it should be "https" instead of "http" prefix. The same client code works fine when execute query directly to another HTTPS presto cluster (no ELB). Here is the client Java code. url is "cluster-elb.mydomain:8443"



      Properties properties = new Properties();
      properties.setProperty("SSL", "true");
      Connection conn = DriverManager.getConnection(url, properties);
      Statement stmt = conn.createStatement();
      String query = "select cluster, query_text from mytable where ds='2018-10-20' limit 10";
      ResultSet rs = stmt.executeQuery(query);


      Why the presto-jdbc client code is confused and how to make the query work?







      amazon-elb prestodb






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 20 at 23:09









      danzhi

      11




      11
























          2 Answers
          2






          active

          oldest

          votes


















          1














          This should work in newer versions of Presto. Try it with 0.213.






          share|improve this answer





















          • I can not quickly try 0.213 yet as the Qubole presto cluster is 0.193 (and as if it is the latest version Qubole support). Do you have a reference of the related commit or other context for review and potential cherry-pick?
            – danzhi
            Nov 21 at 0:14












          • This is probably the one: github.com/prestodb/presto/issues/8232
            – danzhi
            Nov 21 at 0:43










          • @danzhi 0.193 is already quite old. I strongly recommend upgrading. Alternatively you can use presto-proxy for TLS termination. BTW, can you apply custom patches while on Qubole platform?
            – Piotr Findeisen
            Nov 21 at 9:54



















          -1














          The problem is due to https://github.com/prestodb/presto/issues/8232 where the nextUri field in QueryStatusInfo is incorrectly set as http instead of https by presto server (when client talk to presto through elb or proxy).






          share|improve this answer





















          • This issue was fixed a long time ago. The related change was closed, but the attached issue was not. I have closed the issue.
            – Dain Sundstrom
            Nov 22 at 23:33











          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',
          autoActivateHeartbeat: false,
          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%2f53402980%2fpresto-query-through-elb-error-the-plain-http-request-was-sent-to-https%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          This should work in newer versions of Presto. Try it with 0.213.






          share|improve this answer





















          • I can not quickly try 0.213 yet as the Qubole presto cluster is 0.193 (and as if it is the latest version Qubole support). Do you have a reference of the related commit or other context for review and potential cherry-pick?
            – danzhi
            Nov 21 at 0:14












          • This is probably the one: github.com/prestodb/presto/issues/8232
            – danzhi
            Nov 21 at 0:43










          • @danzhi 0.193 is already quite old. I strongly recommend upgrading. Alternatively you can use presto-proxy for TLS termination. BTW, can you apply custom patches while on Qubole platform?
            – Piotr Findeisen
            Nov 21 at 9:54
















          1














          This should work in newer versions of Presto. Try it with 0.213.






          share|improve this answer





















          • I can not quickly try 0.213 yet as the Qubole presto cluster is 0.193 (and as if it is the latest version Qubole support). Do you have a reference of the related commit or other context for review and potential cherry-pick?
            – danzhi
            Nov 21 at 0:14












          • This is probably the one: github.com/prestodb/presto/issues/8232
            – danzhi
            Nov 21 at 0:43










          • @danzhi 0.193 is already quite old. I strongly recommend upgrading. Alternatively you can use presto-proxy for TLS termination. BTW, can you apply custom patches while on Qubole platform?
            – Piotr Findeisen
            Nov 21 at 9:54














          1












          1








          1






          This should work in newer versions of Presto. Try it with 0.213.






          share|improve this answer












          This should work in newer versions of Presto. Try it with 0.213.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 20 at 23:51









          David Phillips

          7,40942944




          7,40942944












          • I can not quickly try 0.213 yet as the Qubole presto cluster is 0.193 (and as if it is the latest version Qubole support). Do you have a reference of the related commit or other context for review and potential cherry-pick?
            – danzhi
            Nov 21 at 0:14












          • This is probably the one: github.com/prestodb/presto/issues/8232
            – danzhi
            Nov 21 at 0:43










          • @danzhi 0.193 is already quite old. I strongly recommend upgrading. Alternatively you can use presto-proxy for TLS termination. BTW, can you apply custom patches while on Qubole platform?
            – Piotr Findeisen
            Nov 21 at 9:54


















          • I can not quickly try 0.213 yet as the Qubole presto cluster is 0.193 (and as if it is the latest version Qubole support). Do you have a reference of the related commit or other context for review and potential cherry-pick?
            – danzhi
            Nov 21 at 0:14












          • This is probably the one: github.com/prestodb/presto/issues/8232
            – danzhi
            Nov 21 at 0:43










          • @danzhi 0.193 is already quite old. I strongly recommend upgrading. Alternatively you can use presto-proxy for TLS termination. BTW, can you apply custom patches while on Qubole platform?
            – Piotr Findeisen
            Nov 21 at 9:54
















          I can not quickly try 0.213 yet as the Qubole presto cluster is 0.193 (and as if it is the latest version Qubole support). Do you have a reference of the related commit or other context for review and potential cherry-pick?
          – danzhi
          Nov 21 at 0:14






          I can not quickly try 0.213 yet as the Qubole presto cluster is 0.193 (and as if it is the latest version Qubole support). Do you have a reference of the related commit or other context for review and potential cherry-pick?
          – danzhi
          Nov 21 at 0:14














          This is probably the one: github.com/prestodb/presto/issues/8232
          – danzhi
          Nov 21 at 0:43




          This is probably the one: github.com/prestodb/presto/issues/8232
          – danzhi
          Nov 21 at 0:43












          @danzhi 0.193 is already quite old. I strongly recommend upgrading. Alternatively you can use presto-proxy for TLS termination. BTW, can you apply custom patches while on Qubole platform?
          – Piotr Findeisen
          Nov 21 at 9:54




          @danzhi 0.193 is already quite old. I strongly recommend upgrading. Alternatively you can use presto-proxy for TLS termination. BTW, can you apply custom patches while on Qubole platform?
          – Piotr Findeisen
          Nov 21 at 9:54













          -1














          The problem is due to https://github.com/prestodb/presto/issues/8232 where the nextUri field in QueryStatusInfo is incorrectly set as http instead of https by presto server (when client talk to presto through elb or proxy).






          share|improve this answer





















          • This issue was fixed a long time ago. The related change was closed, but the attached issue was not. I have closed the issue.
            – Dain Sundstrom
            Nov 22 at 23:33
















          -1














          The problem is due to https://github.com/prestodb/presto/issues/8232 where the nextUri field in QueryStatusInfo is incorrectly set as http instead of https by presto server (when client talk to presto through elb or proxy).






          share|improve this answer





















          • This issue was fixed a long time ago. The related change was closed, but the attached issue was not. I have closed the issue.
            – Dain Sundstrom
            Nov 22 at 23:33














          -1












          -1








          -1






          The problem is due to https://github.com/prestodb/presto/issues/8232 where the nextUri field in QueryStatusInfo is incorrectly set as http instead of https by presto server (when client talk to presto through elb or proxy).






          share|improve this answer












          The problem is due to https://github.com/prestodb/presto/issues/8232 where the nextUri field in QueryStatusInfo is incorrectly set as http instead of https by presto server (when client talk to presto through elb or proxy).







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 21 at 1:48









          danzhi

          11




          11












          • This issue was fixed a long time ago. The related change was closed, but the attached issue was not. I have closed the issue.
            – Dain Sundstrom
            Nov 22 at 23:33


















          • This issue was fixed a long time ago. The related change was closed, but the attached issue was not. I have closed the issue.
            – Dain Sundstrom
            Nov 22 at 23:33
















          This issue was fixed a long time ago. The related change was closed, but the attached issue was not. I have closed the issue.
          – Dain Sundstrom
          Nov 22 at 23:33




          This issue was fixed a long time ago. The related change was closed, but the attached issue was not. I have closed the issue.
          – Dain Sundstrom
          Nov 22 at 23:33


















          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%2f53402980%2fpresto-query-through-elb-error-the-plain-http-request-was-sent-to-https%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

          404 Error Contact Form 7 ajax form submitting

          How to know if a Active Directory user can login interactively

          Refactoring coordinates for Minecraft Pi buildings written in Python