当将AWS ELB (弹性负载均衡器)与HTTPS侦听器一起使用时,使用presto-jdbc (0.213)的Java客户端将请求转发到在HTTP上运行的presto群集(0.213)后,由于出现“普通HTTP请求已发送到HTTPS端口”错误而无法执行select查询。
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代码试图访问"http://cluster-elb.mydomain:8443/...“这是ELB地址,除了它应该是"https“而不是"http”前缀。当直接对另一个HTTPS presto集群(无ELB)执行查询时,相同的客户端代码工作得很好。以下是客户端Java代码。url是"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客户端代码很混乱,如何使查询工作?
发布于 2018-11-21 07:51:17
这应该可以在较新版本的Presto中工作。用0.213试试吧。
发布于 2018-11-21 09:48:33
该问题是由于https://github.com/prestodb/presto/issues/8232造成的,其中presto服务器将QueryStatusInfo中的https字段错误地设置为http而不是https(当客户端通过elb或proxy与presto交谈时)。
https://stackoverflow.com/questions/53402980
复制相似问题