WebSocket长链接NSError.code返回61 或者 57

解决方法:在RCTWebSocketExecutor.m文件中修改setup函数中的localhost为你电脑的IP地址(例如:192.168.0.104)

修改前代码:

- (void)setUp

{

if (!_url) {

NSUserDefaults *standardDefaults = [NSUserDefaults standardUserDefaults];

NSInteger port = [standardDefaults integerForKey:@"websocket-executor-port"] ?: 8081;

NSString *URLString = [NSString stringWithFormat:@"http://localhost:%zd/debugger-proxy", port];

_url = [RCTConvert NSURL:URLString];

}

// 此处省略后面代码

}

修改后代码:

- (void)setUp

{

if (!_url) {

NSUserDefaults *standardDefaults = [NSUserDefaults standardUserDefaults];

NSInteger port = [standardDefaults integerForKey:@"websocket-executor-port"] ?: 8081;

NSString *URLString = [NSString stringWithFormat:@"http://192.168.0.104:%zd/debugger-proxy", port];

_url = [RCTConvert NSURL:URLString];

}

// 此处省略后面代码

}

你可能感兴趣的:(WebSocket长链接NSError.code返回61 或者 57)