我的iOS应用程序在IPv6下运行良好,但连接到XMPP时出错。 Android没有错误

我的iOS应用程序在IPv6下运行良好,但连接到XMPP时出错。 Android没有错误

问题描述:

图片正在测试服务器的域名。我通过端口5222连接XMPP,失败的原因:我的iOS应用程序在IPv6下运行良好,但连接到XMPP时出错。 Android没有错误

Error Domain=NSPOSIXErrorDomain 
Code=51 "Network is unreachable" 
UserInfo={ 
    NSLocalizedDescription=Network is unreachable, 
    NSLocalizedFailureReason=Error in connect() function} 

enter image description here

XMPPStream.m文件,去init功能,只需将线下

asyncSocket = [[GCDAsyncSocket alloc] initWithDelegate:self delegateQueue:xmppQueue]; 

添加以下行

[asyncSocket setPreferIPv4OverIPv6:NO]; 

聊天将在两个IPV4 & IPV6 then

+0

谢谢!这个对我有用。 – Lim