当使用带有HTTPS侦听器的AWS ELB(弹性负载平衡器)将请求转发到在HTTP上运行的后面的presto群集(0.193)时,使用presto-jdbc(0.213)的Java客户端由于以下原因而无法执行选择查询: “普通HTTP请求已发送到HTTPS端口”错误。
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
似乎StatementClientV1.advance代码尝试访问ELB地址“ http://cluster-elb.mydomain:8443/ ...”,只是它应为“ https”而不是“ http”前缀。直接执行查询到另一个HTTPS presto群集(无ELB)时,相同的客户端代码可以正常工作。这是客户端Java代码。网址为“ 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);
为什么presto-jdbc客户端代码混乱,如何使查询正常工作?
答案 0 :(得分:1)
这应该在更新版本的Presto中起作用。尝试使用0.213。
答案 1 :(得分:-1)
问题是由于https://github.com/prestodb/presto/issues/8232所致,presto服务器将QueryStatusInfo中的nextUri字段错误地设置为http而不是https(当客户端通过elb或proxy与presto对话时)。