gpt4 book ai didi

https - SocketIOException : Unexpected handshake error in client

转载 作者:行者123 更新时间:2023-12-01 10:32:56 25 4
gpt4 key购买 nike

以下异常:

SocketIOException: Unexpected handshake error in client (OS Error: errno = -12268)
#0 _SecureFilterImpl.handshake (dart:io-patch:849:8)
#1 _SecureSocket._secureHandshake (dart:io:7382:28)
#2 _SecureSocket._secureConnectHandler._secureConnectHandler (dart:io:7294:21)
#3 _Socket._updateOutHandler.firstWriteHandler (dart:io-patch:773:64)
#4 _SocketBase._multiplex (dart:io-patch:408:26)
#5 _SocketBase._sendToEventHandler.<anonymous closure> (dart:io-patch:509:20)
#6 _ReceivePortImpl._handleMessage (dart:isolate-patch:37:92)

以下代码的结果:

String url = "https://www.google.com";
HttpClient client = new HttpClient();
HttpClientConnection conn = client.getUrl(new Uri(url));
conn.onResponse = (HttpClientResponse resp) {
print ('content length ${resp.contentLength}');
print ('status code ${resp.statusCode}');
InputStream input = resp.inputStream;
input.onData = () {
print(codepointsToString(input.read()));
};
input.onClosed = () {
print('closed!');
client.shutdown();
};
};

请注意,如果我将 url 替换为“http”而不是“https”,它会按预期工作。

Bug report is here.

最佳答案

更新 : 见answer of William Hesse对于 Dart 版本 >= 1.12。

我对 Dart SDK version 0.2.9.9_r16323 也有同样的错误.在 the issue 7541 :

The SecureSocket library needs to be initialized explicitly before using secure networking. We are working on making it initialize automatically the first time you use it, but that is not committed yet. To use just the default root certificates (well known certificate authorities), call SecureSocket.initialize() in your main() routine, before you do any networking.



因此,通过添加 SecureSocket.initialize()在您的代码之前,它按预期工作。

r16384这个明确的 initialization is optional .

SecureSocket.initialize() is now optional. If you don't call it, it is the same as if you had called it with no parameters. If you call it explicitly, you must do so once, and before creating any secure connections. You need to call it explicitly if you are making server sockets, since they need a certificate database and a password for the key database.

关于https - SocketIOException : Unexpected handshake error in client,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13964492/

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