当我测试断开连接后重新连接的项目时,我使用这种方式:关闭并重新打开wifi。
第15次后,iPhone无法连接插座。但是,其他 iPhone 或 android 手机可以连接。
终端日志:
2021-03-18 13:28:37.807943+0800 Rippton[34550:3851342] [] tcp_connection_is_cellular No connected path
2021-03-18 13:28:37.809233+0800 Rippton[34550:3852231] [] nw_socket_initialize_socket setsockopt SO_NOSIGPIPE failed [22: Invalid argument]
2021-03-18 13:28:37.809330+0800 Rippton[34550:3852231] [] nw_socket_initialize_socket [C159:1] setsockopt SO_NECP_CLIENTUUID failed [22: Invalid argument]
2021-03-18 13:28:37.809401+0800 Rippton[34550:3852231] [] nw_socket_initialize_socket setsockopt SO_NECP_CLIENTUUID failed [22: Invalid argument]
2021-03-18 13:28:37.809458+0800 Rippton[34550:3851043] TcpMavlink.m:172 -[TcpMavlink socketDidDisconnect:withError:] rover disconnect,ip-(null), port-0
2021-03-18 13:28:37.811502+0800 Rippton[34550:3852231] [] nw_socket_handle_socket_event [C159:1] Socket SO_ERROR [54: Connection reset by peer]
我的重连码:
- (void)ConnectServer {
if (self.clientSocket!=nil) {
[self.clientSocket disconnect];
self.clientSocket=nil;
}
self.clientSocket = [[GCDAsyncSocket alloc] initWithDelegate:self delegateQueue:dispatch_get_main_queue()];
self.clientSocket.delegate=self;
NSError *error = nil;
[self.clientSocket connectToHost:define.MAVLINK_IP onPort:define.MAVLINK_PORT viaInterface:nil withTimeout:1 error:&error];
}