gpt4 book ai didi

java - SSLHandShakeException : Remote host closed connection during handshake making GET Request

转载 作者:太空宇宙 更新时间:2023-11-03 14:34:52 25 4
gpt4 key购买 nike

这是我正在使用的代码

UriComponentsBuilder builder = UriComponentsBuilder
.newInstance()
.host(HOST)
.scheme("https")
.path("/query");

builder.queryParam("function", "TIME_SERIES_INTRADAY");
builder.queryParam("symbol", exchange.isEmpty() ? ticker : (exchange + ":" + ticker));
builder.queryParam("interval", "30min");
builder.queryParam("apikey", System.getenv("LEO_ALPHA_VANTAGE_KEY_12"));

try {
URL uri = new URL(builder.build().toUriString());
System.setProperty("https.protocols", "TLSv1.2");
HttpURLConnection connection = (HttpURLConnection) uri.openConnection();

导致此异常的原因是打开了 debug=all 并且我也打开了 tls1.2

main, WRITE: TLSv1.2 Handshake, length = 237
[Raw write]: length = 242
0000: 16 03 03 00 ED 01 00 00 E9 03 03 5A 8B 6B 97 B1 ...........Z.k..
0010: 9D 19 5F 18 2A F5 32 F0 32 FE 29 64 31 0B A2 8C .._.*.2.2.)d1...
0020: A6 57 80 79 AE F7 7F D3 12 40 02 00 00 64 C0 24 .W.y.....@...d.$
0030: C0 28 00 3D C0 26 C0 2A 00 6B 00 6A C0 0A C0 14 .(.=.&.*.k.j....
0040: 00 35 C0 05 C0 0F 00 39 00 38 C0 23 C0 27 00 3C .5.....9.8.#.'.<
0050: C0 25 C0 29 00 67 00 40 C0 09 C0 13 00 2F C0 04 .%.).g.@...../..
0060: C0 0E 00 33 00 32 C0 2C C0 2B C0 30 00 9D C0 2E ...3.2.,.+.0....
0070: C0 32 00 9F 00 A3 C0 2F 00 9C C0 2D C0 31 00 9E .2...../...-.1..
0080: 00 A2 C0 08 C0 12 00 0A C0 03 C0 0D 00 16 00 13 ................
0090: 00 FF 01 00 00 5C 00 0A 00 16 00 14 00 17 00 18 .....\..........
00A0: 00 19 00 09 00 0A 00 0B 00 0C 00 0D 00 0E 00 16 ................
00B0: 00 0B 00 02 01 00 00 0D 00 1C 00 1A 06 03 06 01 ................
00C0: 05 03 05 01 04 03 04 01 04 02 03 03 03 01 03 02 ................
00D0: 02 03 02 01 02 02 00 17 00 00 00 00 00 14 00 12 ................
00E0: 00 00 0F 61 6C 70 68 61 76 61 6E 74 61 67 65 2E ...alphavantage.
00F0: 63 6F co
main, received EOFException: error
main, handling exception: javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake
main, SEND TLSv1.2 ALERT: fatal, description = handshake_failure
main, WRITE: TLSv1.2 Alert, length = 2
[Raw write]: length = 7
0000: 15 03 03 00 02 02 28 ......(
main, called closeSocket()
Exception in thread "main" java.lang.RuntimeException: javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake
at com.compass.leo.util.AlphaVantage.getStockTimeSeries(AlphaVantage.java:128)
at com.compass.leo.util.AlphaVantage.getStockTimeSeries(AlphaVantage.java:84)
at com.compass.leo.LeoApplication.main(LeoApplication.java:42)
Caused by: javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake
at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1002)
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1385)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1413)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1397)
at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:559)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:185)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1564)
at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:480)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:347)
at

com.compass.leo.util.AlphaVantage.getStockTimeSeries(AlphaVantage.java:116)
... 2 more
Caused by: java.io.EOFException: SSL peer shut down incorrectly
at sun.security.ssl.InputRecord.read(InputRecord.java:505)
at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:983)
... 12 more

我想知道这里会出现什么错误?我可以通过 postman 轻松地调用这个网站的电话,

GET 请求:https://www.alphavantage.co/query?function=TIME_SERIES_INTRADAY&symbol=TSX:CPG&interval=30min&apikey=demo

这可能是什么问题?

最佳答案

有一次我遇到了类似的问题,我花了 2 天时间才弄明白。我不知道这是否会成为你的情况,但它可能值得一试。

我在有代理阻止请求的服务器上运行应用程序。当我发送 https://my-server/my-service请求它将从公司返回一个 HTTP 页面,上面写着“内容被 IT 阻止”。此 HTTP 页面无法完成握手,因为它不是 HTTPS 页面。

解决方案是要求 IT 将服务器上的域列入白名单。

关于java - SSLHandShakeException : Remote host closed connection during handshake making GET Request,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48876340/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com