反应本机缓慢的初始SSL连接,然后快速

时间:2019-07-10 10:23:03

标签: react-native ssl amazon-ec2 fetch-api boringssl

我的react native应用通过SSL连接到我的API,但是第一次与服务器的连接通常非常缓慢(有时长达20秒)。在4G上,这明显比Wifi差。奇怪的是,一旦连接成功,随后的连接就会迅速闪电起来。我正在使用“让我们加密SSL”证书在AWS服务器上运行REST API。

为这个模糊的问题表示歉意,但恐怕我不知道该如何描述这个问题,或者不知道从哪里开始对其进行优化。与DNS有关吗?还是握手?在React Native方面,我似乎没有太多可以调整的地方,因此任何想法都将不胜感激。

欢呼

编辑:这是尝试联系服务器时来自XCode的日志。最终确实建立了连接,但仅在l

之后

2019-07-10 11:26:57.859957+0100 myappname[1420:173102] [] nw_socket_handle_socket_event [C913.2:1] Socket SO_ERROR [61: Connection refused]
2019-07-10 11:26:57.861100+0100 myappname[1420:173102] [] nw_connection_get_connected_socket [C913] Client called nw_connection_get_connected_socket on unconnected nw_connection
2019-07-10 11:26:57.861206+0100 myappname[1420:173102] TCP Conn 0x28160ac40 Failed : error 0:61 [61]
2019-07-10 11:27:00.067880+0100 myappname[1420:180490] [] nw_connection_get_connected_socket [C914] Client called nw_connection_get_connected_socket on unconnected nw_connection
2019-07-10 11:27:00.067919+0100 myappname[1420:180490] TCP Conn 0x281629140 Failed : error 0:61 [61]
2019-07-10 11:27:02.277133+0100 myappname[1420:180221] [] nw_connection_get_connected_socket [C915] Client called nw_connection_get_connected_socket on unconnected nw_connection
2019-07-10 11:27:02.277266+0100 myappname[1420:180221] TCP Conn 0x28162a280 Failed : error 0:61 [61]
2019-07-10 11:27:04.472363+0100 myappname[1420:180221] [] nw_socket_connect [C916.1:1] connectx(18, [srcif=0, srcaddr=<NULL>, dstaddr=127.0.0.1:8081], SAE_ASSOCID_ANY, 0, NULL, 0, NULL, SAE_CONNID_ANY) failed: [61: Connection refused]
2019-07-10 11:27:04.472683+0100 myappname[1420:180221] [] nw_socket_connect [C916.1:1] connectx failed (fd 18) [61: Connection refused]
2019-07-10 11:27:04.472740+0100 myappname[1420:180221] [] nw_socket_connect connectx failed (fd 18) [61: Connection refused]
2019-07-10 11:27:04.477835+0100 myappname[1420:173102] [] nw_connection_get_connected_socket [C916] Client called nw_connection_get_connected_socket on unconnected nw_connection
2019-07-10 11:27:04.477919+0100 myappname[1420:173102] TCP Conn 0x28163c480 Failed : error 0:61 [61]
2019-07-10 11:27:04.999439+0100 myappname[1420:173102] [BoringSSL] nw_protocol_boringssl_input_finished(1543) [C911.1:2][0x15960f130] Peer disconnected during the middle of a handshake. Sending errSSLClosedNoNotify(-9816) alert
2019-07-10 11:27:05.006831+0100 myappname[1420:173102] TIC TCP Conn Failed [911:0x28163fe40]: 3:-9816 Err(-9816)
2019-07-10 11:27:05.009867+0100 myappname[1420:173102] NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9816)
2019-07-10 11:27:05.010062+0100 myappname[1420:173102] Task <3B392DA9-8867-480D-A0A1-22F47204AC12>.<11> HTTP load failed (error code: -1200 [3:-9816])
2019-07-10 11:27:05.011144+0100 myappname[1420:173102] Task <3B392DA9-8867-480D-A0A1-22F47204AC12>.<11> finished with error - code: -1200
2019-07-10 11:27:05.014633+0100 myappname[1420:180490] Task <3B392DA9-8867-480D-A0A1-22F47204AC12>.<11> load failed with error Error Domain=NSURLErrorDomain Code=-1200 "An SSL error has occurred and a secure connection to the server cannot be made." UserInfo={NSErrorFailingURLStringKey=https://myappname.com/api/v1/users/me/7347, NSLocalizedRecoverySuggestion=Would you like to connect to the server anyway?, _kCFStreamErrorDomainKey=3, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <3B392DA9-8867-480D-A0A1-22F47204AC12>.<11>, _NSURLErrorRelatedURLSessionTaskErrorKey=(
    "LocalDataTask <3B392DA9-8867-480D-A0A1-22F47204AC12>.<11>"
), NSLocalizedDescription=An SSL error has occurred and a secure connection to the server cannot be made., NSErrorFailingURLKey=https://myappname.com/api/v1/users/me/7347, NSUnderlyingError=0x28751a190 {Error Domain=kCFErrorDomainCFNetwork Code=-1200 "(null)" UserInfo={_kCFStreamPropertySSLClientCertificateState=0, _kCFNetworkCFStreamSSLErrorOriginalValue=-9816, _kCFStreamErrorDomainKey=3, _kCFStreamErrorCodeKey=-9816}}, _kCFStreamErrorCodeKey=-9816} [-1200]

0 个答案:

没有答案