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

2016-12-21  本文已影响39人  muyang_js的简书

解决方法:在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];

}

// 此处省略后面代码

}

上一篇 下一篇

猜你喜欢

热点阅读