无法与任何提供的主机建立套接字
Could not establish socket with any provided host
我正在努力处理 android.I 中的文件传输,我正在使用 smack 4.1 连接到 openfire 服务器。
我的问题是:
当我使用 Spark 到 Spark 文件传输时,当我将文件从 Spark 传输到 Android 或从 Android 传输到 Android[=47= 时,它工作 fine.But ], iq received showing error "Could not establish socket with any provided host" like this:
<iq id="018vq-231" to="sender@domain.com/Spark 2.6.3" from="receiver@domain.com/Smack" type="error">
<error code="-1" type="CANCEL">
<item-not-found xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/>
<text xmlns="urn:ietf:params:xml:ns:xmpp-stanzas" xml:lang="en">Could not establish socket with any provided host</text>
</error>
</iq>
我的接收码是:
FileTransferManager fileTransferManager = FileTransferManager.getInstanceFor(xmppTcpConnection);
fileTransferManager .addFileTransferListener(new FileTransferListener() {
@Override
public void fileTransferRequest(final FileTransferRequest request) {
final IncomingFileTransfer transfer = request.accept();
File file = new File("Path/To/Save", transfer.getFileName());
transfer.recieveFile(file);
}
});
我的 ProviderManager 代码是:
我将 ServiceDiscoveryManager 和 ProviderManager 用作:
ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(AppConstant.xmppTcpConnection);
sdm.addFeature("http://jabber.org/protocol/disco#info");
sdm.addFeature("jabber:iq:privacy");
sdm.addFeature("jabber.org/protocol/si");
ProviderManager.addIQProvider("query",
"http://jabber.org/protocol/bytestreams", new BytestreamsProvider());
ProviderManager.addIQProvider("query",
"http://jabber.org/protocol/disco#items", new DiscoverItemsProvider());
ProviderManager.addIQProvider("query",
"http://jabber.org/protocol/disco#info", new DiscoverInfoProvider());
ProviderManager.addIQProvider("si","http://jabber.org/protocol/si",new StreamInitiationProvider());
并且,我还注册了一个 Negotiator 作为:
FileTransferNegotiator fileTransferNegotiator = FileTransferNegotiator.getInstanceFor(xmppTcpConnection);
我还在 spark 调试器中注意到: 当 spark 到 spark 传输时,会出现相同的消息,即无法与任何提供的主机建立套接字,但随后 spark 协商流和文件是已转移。
但是从 spark 传输到 android 时,从 android 设备接收到具有相同错误的 iq 并且协商由 spark 发起但我端未收到文件。
谁能指导我正确的方法。
谢谢。
更新:
Iq Sent :
<iq id="018vq-245" to="receiver@mydomain.com/Smack" from="sender@mydomain.com/Spark 2.6.3" type="set">
<si xmlns="http://jabber.org/protocol/si" id="jsi_4357088093390871541" mime-type="image/jpeg" profile="http://jabber.org/protocol/si/profile/file-transfer">
<file xmlns="http://jabber.org/protocol/si/profile/file-transfer" name="23janNetaji.jpg" size="63856">
<desc>Sending</desc>
</file>
<feature xmlns="http://jabber.org/protocol/feature-neg">
<x xmlns="jabber:x:data" type="form">
<field var="stream-method" type="list-single">
<option>
<value>http://jabber.org/protocol/bytestreams</value>
</option>
<option>
<value>http://jabber.org/protocol/ibb</value>
</option>
</field>
</x>
</feature>
</si>
</iq>
Received :
<iq id="018vq-245" to="sender@mydomain.com/Spark 2.6.3" from="receiver@mydomain.com/Smack" type="result">
<si xmlns="http://jabber.org/protocol/si">
<feature xmlns="http://jabber.org/protocol/feature-neg">
<x xmlns="jabber:x:data" type="submit">
<field var="stream-method">
<value>http://jabber.org/protocol/bytestreams</value>
<value>http://jabber.org/protocol/ibb</value>
</field>
</x>
</feature>
</si>
</iq>
Sent :
<iq id="018vq-246" to="receiver@mydomain.com/Smack" type="get">
<query xmlns="http://jabber.org/protocol/disco#info"/>
</iq>
Received :
<iq id="018vq-246" to="sender@mydomain.com/Spark 2.6.3" from="receiver@mydomain.com/Smack" type="result">
<query xmlns="http://jabber.org/protocol/disco#info">
<identity category="client" name="Smack" type="pc"/>
<feature var="http://jabber.org/protocol/commands"/>
<feature var="http://jabber.org/protocol/xhtml-im"/>
<feature var="jabber.org/protocol/si"/>
<feature var="jabber:iq:privacy"/>
<feature var="vcard-temp"/>
<feature var="http://jabber.org/protocol/disco#items"/>
<feature var="urn:xmpp:time"/>
<feature var="jabber:iq:last"/>
<feature var="jabber:x:data"/>
<feature var="urn:xmpp:ping"/>
<feature var="http://jabber.org/protocol/bytestreams"/>
<feature var="http://jabber.org/protocol/ibb"/>
<feature var="http://jabber.org/protocol/muc"/>
<feature var="http://jabber.org/protocol/si"/>
<feature var="http://jabber.org/protocol/xdata-validate"/>
<feature var="jabber:iq:version"/>
<feature var="http://jabber.org/protocol/xdata-layout"/>
<feature var="http://jabber.org/protocol/si/profile/file-transfer"/>
<feature var="urn:xmpp:receipts"/>
<feature var="http://jabber.org/protocol/caps"/>
<feature var="http://jabber.org/protocol/disco#info"/>
</query>
</iq>
Sent :
<iq id="018vq-247" to="mydomain.com" type="get">
<query xmlns="http://jabber.org/protocol/disco#items"/>
</iq>
Received :
<iq id="018vq-247" to="sender@mydomain.com/Spark 2.6.3" from="mydomain.com" type="result">
<query xmlns="http://jabber.org/protocol/disco#items">
<item jid="search.mydomain.com" name="User Search"/>
<item jid="icq.mydomain.com" name="ICQ Transport"/>
<item jid="relay.mydomain.com" name="JingleRelayNode"/>
<item jid="facebook.mydomain.com" name="Facebook Transport"/>
<item jid="updater.mydomain.com" name="Spark Updater"/>
<item jid="sipark.mydomain.com" name="SIP Controller"/>
<item jid="yahoo.mydomain.com" name="Yahoo! Transport"/>
<item jid="rayo.mydomain.com" name="rayo"/>
<item jid="pubsub.mydomain.com" name="Publish-Subscribe service"/>
<item jid="manager.mydomain.com" name="Client Control Manager"/>
<item jid="baveling.mydomain.com" name="Public Chatrooms"/>
<item jid="msn.mydomain.com" name="MSN Transport"/>
<item jid="conference.mydomain.com" name="Public Chatrooms"/>
<item jid="proxy.mydomain.com" name="Socks 5 Bytestreams Proxy"/>
<item jid="gtalk.mydomain.com" name="Google Talk Transport"/>
<item jid="jitsi-videobridge.mydomain.com" name="JitsiVideobridge"/>
<item jid="aim.mydomain.com" name="AIM Transport"/>
<item jid="workgroup.mydomain.com" name="Fastpath"/>
<item jid="xmpp.mydomain.com" name="XMPP Transport"/>
<item jid="broadcast.mydomain.com" name="Broadcast service"/>
<item jid="logger.mydomain.com" name="Remote Logger"/>
</query>
</iq>
Sent :
<iq id="018vq-248" to="proxy.mydomain.com" type="get">
<query xmlns="http://jabber.org/protocol/disco#info"/>
</iq>
Received :
<iq id="018vq-248" to="sender@mydomain.com/Spark 2.6.3" from="proxy.mydomain.com" type="result">
<query xmlns="http://jabber.org/protocol/disco#info">
<identity category="proxy" name="SOCKS5 Bytestreams Service" type="bytestreams"/>
<feature var="http://jabber.org/protocol/bytestreams"/>
<feature var="http://jabber.org/protocol/disco#info"/>
</query>
</iq>
Sent :
<iq id="018vq-249" to="proxy.mydomain.com" type="get">
<query xmlns="http://jabber.org/protocol/bytestreams"/>
</iq>
Received :
<iq id="018vq-249" to="sender@mydomain.com/Spark 2.6.3" from="proxy.mydomain.com" type="result">
<query xmlns="http://jabber.org/protocol/bytestreams">
<streamhost jid="proxy.mydomain.com" host="mydomain.com" port="7777"/>
</query>
</iq>
Sent :
<iq id="018vq-250" to="receiver@mydomain.com/Smack" type="set">
<query xmlns="http://jabber.org/protocol/bytestreams" sid="jsi_4357088093390871541" mode="tcp">
<streamhost jid="sender@mydomain.com/Spark 2.6.3" host="192.168.1.201" port="7777"/>
<streamhost jid="proxy.mydomain.com" host="mydomain.com" port="7777"/>
</query>
</iq>
Received :
<iq id="018vq-250" to="sender@mydomain.com/Spark 2.6.3" from="receiver@mydomain.com/Smack" type="error">
<error code="-1" type="CANCEL">
<item-not-found xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/>
<text xmlns="urn:ietf:params:xml:ns:xmpp-stanzas" xml:lang="en">Could not establish socket with any provided host</text>
</error>
</iq>
Sent :
<iq id="018vq-251" to="receiver@mydomain.com/Smack" type="set">
<open xmlns="http://jabber.org/protocol/ibb" block-size="4096" sid="jsi_4357088093390871541" stanza="iq"/>
</iq>
sender端收到error IQ后,sender再次向receiver发送IQ文件传输协商流,但此iq后没有收到receiver端的iq
此外,我正在使用以下 smack 库:
compile 'org.igniterealtime.smack:smack-android:4.1.1'
compile 'org.igniterealtime.smack:smack-core:4.1.1'
compile 'org.igniterealtime.smack:smack-tcp:4.1.1'
compile 'org.igniterealtime.smack:smack-extensions:4.1.1'
我得到 solution.The 问题是 smack sdk。
Smack 在文件传输实现中有一些错误:在我的例子中,发起者提供字节流和 ibb 方法,响应者接受这两种(这是错误的)方法。
(参考:@vitalyster 在这里回答Getting ExecutionException on receiving file using asmack in Android)
它应该只接受一个。
因此,在创建 FileNegotiator 时,我只提供了一个流:
FileTransferNegotiator fileTransferNegotiator = FileTransferNegotiator.getInstanceFor(xmppTcpConnection);
FileTransferNegotiator.IBB_ONLY = true;
现在文件传输工作正常。
谢谢大家
我正在努力处理 android.I 中的文件传输,我正在使用 smack 4.1 连接到 openfire 服务器。
我的问题是: 当我使用 Spark 到 Spark 文件传输时,当我将文件从 Spark 传输到 Android 或从 Android 传输到 Android[=47= 时,它工作 fine.But ], iq received showing error "Could not establish socket with any provided host" like this:
<iq id="018vq-231" to="sender@domain.com/Spark 2.6.3" from="receiver@domain.com/Smack" type="error">
<error code="-1" type="CANCEL">
<item-not-found xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/>
<text xmlns="urn:ietf:params:xml:ns:xmpp-stanzas" xml:lang="en">Could not establish socket with any provided host</text>
</error>
</iq>
我的接收码是:
FileTransferManager fileTransferManager = FileTransferManager.getInstanceFor(xmppTcpConnection);
fileTransferManager .addFileTransferListener(new FileTransferListener() {
@Override
public void fileTransferRequest(final FileTransferRequest request) {
final IncomingFileTransfer transfer = request.accept();
File file = new File("Path/To/Save", transfer.getFileName());
transfer.recieveFile(file);
}
});
我的 ProviderManager 代码是:
我将 ServiceDiscoveryManager 和 ProviderManager 用作:
ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(AppConstant.xmppTcpConnection);
sdm.addFeature("http://jabber.org/protocol/disco#info");
sdm.addFeature("jabber:iq:privacy");
sdm.addFeature("jabber.org/protocol/si");
ProviderManager.addIQProvider("query",
"http://jabber.org/protocol/bytestreams", new BytestreamsProvider());
ProviderManager.addIQProvider("query",
"http://jabber.org/protocol/disco#items", new DiscoverItemsProvider());
ProviderManager.addIQProvider("query",
"http://jabber.org/protocol/disco#info", new DiscoverInfoProvider());
ProviderManager.addIQProvider("si","http://jabber.org/protocol/si",new StreamInitiationProvider());
并且,我还注册了一个 Negotiator 作为:
FileTransferNegotiator fileTransferNegotiator = FileTransferNegotiator.getInstanceFor(xmppTcpConnection);
我还在 spark 调试器中注意到: 当 spark 到 spark 传输时,会出现相同的消息,即无法与任何提供的主机建立套接字,但随后 spark 协商流和文件是已转移。
但是从 spark 传输到 android 时,从 android 设备接收到具有相同错误的 iq 并且协商由 spark 发起但我端未收到文件。
谁能指导我正确的方法。
谢谢。
更新:
Iq Sent :
<iq id="018vq-245" to="receiver@mydomain.com/Smack" from="sender@mydomain.com/Spark 2.6.3" type="set">
<si xmlns="http://jabber.org/protocol/si" id="jsi_4357088093390871541" mime-type="image/jpeg" profile="http://jabber.org/protocol/si/profile/file-transfer">
<file xmlns="http://jabber.org/protocol/si/profile/file-transfer" name="23janNetaji.jpg" size="63856">
<desc>Sending</desc>
</file>
<feature xmlns="http://jabber.org/protocol/feature-neg">
<x xmlns="jabber:x:data" type="form">
<field var="stream-method" type="list-single">
<option>
<value>http://jabber.org/protocol/bytestreams</value>
</option>
<option>
<value>http://jabber.org/protocol/ibb</value>
</option>
</field>
</x>
</feature>
</si>
</iq>
Received :
<iq id="018vq-245" to="sender@mydomain.com/Spark 2.6.3" from="receiver@mydomain.com/Smack" type="result">
<si xmlns="http://jabber.org/protocol/si">
<feature xmlns="http://jabber.org/protocol/feature-neg">
<x xmlns="jabber:x:data" type="submit">
<field var="stream-method">
<value>http://jabber.org/protocol/bytestreams</value>
<value>http://jabber.org/protocol/ibb</value>
</field>
</x>
</feature>
</si>
</iq>
Sent :
<iq id="018vq-246" to="receiver@mydomain.com/Smack" type="get">
<query xmlns="http://jabber.org/protocol/disco#info"/>
</iq>
Received :
<iq id="018vq-246" to="sender@mydomain.com/Spark 2.6.3" from="receiver@mydomain.com/Smack" type="result">
<query xmlns="http://jabber.org/protocol/disco#info">
<identity category="client" name="Smack" type="pc"/>
<feature var="http://jabber.org/protocol/commands"/>
<feature var="http://jabber.org/protocol/xhtml-im"/>
<feature var="jabber.org/protocol/si"/>
<feature var="jabber:iq:privacy"/>
<feature var="vcard-temp"/>
<feature var="http://jabber.org/protocol/disco#items"/>
<feature var="urn:xmpp:time"/>
<feature var="jabber:iq:last"/>
<feature var="jabber:x:data"/>
<feature var="urn:xmpp:ping"/>
<feature var="http://jabber.org/protocol/bytestreams"/>
<feature var="http://jabber.org/protocol/ibb"/>
<feature var="http://jabber.org/protocol/muc"/>
<feature var="http://jabber.org/protocol/si"/>
<feature var="http://jabber.org/protocol/xdata-validate"/>
<feature var="jabber:iq:version"/>
<feature var="http://jabber.org/protocol/xdata-layout"/>
<feature var="http://jabber.org/protocol/si/profile/file-transfer"/>
<feature var="urn:xmpp:receipts"/>
<feature var="http://jabber.org/protocol/caps"/>
<feature var="http://jabber.org/protocol/disco#info"/>
</query>
</iq>
Sent :
<iq id="018vq-247" to="mydomain.com" type="get">
<query xmlns="http://jabber.org/protocol/disco#items"/>
</iq>
Received :
<iq id="018vq-247" to="sender@mydomain.com/Spark 2.6.3" from="mydomain.com" type="result">
<query xmlns="http://jabber.org/protocol/disco#items">
<item jid="search.mydomain.com" name="User Search"/>
<item jid="icq.mydomain.com" name="ICQ Transport"/>
<item jid="relay.mydomain.com" name="JingleRelayNode"/>
<item jid="facebook.mydomain.com" name="Facebook Transport"/>
<item jid="updater.mydomain.com" name="Spark Updater"/>
<item jid="sipark.mydomain.com" name="SIP Controller"/>
<item jid="yahoo.mydomain.com" name="Yahoo! Transport"/>
<item jid="rayo.mydomain.com" name="rayo"/>
<item jid="pubsub.mydomain.com" name="Publish-Subscribe service"/>
<item jid="manager.mydomain.com" name="Client Control Manager"/>
<item jid="baveling.mydomain.com" name="Public Chatrooms"/>
<item jid="msn.mydomain.com" name="MSN Transport"/>
<item jid="conference.mydomain.com" name="Public Chatrooms"/>
<item jid="proxy.mydomain.com" name="Socks 5 Bytestreams Proxy"/>
<item jid="gtalk.mydomain.com" name="Google Talk Transport"/>
<item jid="jitsi-videobridge.mydomain.com" name="JitsiVideobridge"/>
<item jid="aim.mydomain.com" name="AIM Transport"/>
<item jid="workgroup.mydomain.com" name="Fastpath"/>
<item jid="xmpp.mydomain.com" name="XMPP Transport"/>
<item jid="broadcast.mydomain.com" name="Broadcast service"/>
<item jid="logger.mydomain.com" name="Remote Logger"/>
</query>
</iq>
Sent :
<iq id="018vq-248" to="proxy.mydomain.com" type="get">
<query xmlns="http://jabber.org/protocol/disco#info"/>
</iq>
Received :
<iq id="018vq-248" to="sender@mydomain.com/Spark 2.6.3" from="proxy.mydomain.com" type="result">
<query xmlns="http://jabber.org/protocol/disco#info">
<identity category="proxy" name="SOCKS5 Bytestreams Service" type="bytestreams"/>
<feature var="http://jabber.org/protocol/bytestreams"/>
<feature var="http://jabber.org/protocol/disco#info"/>
</query>
</iq>
Sent :
<iq id="018vq-249" to="proxy.mydomain.com" type="get">
<query xmlns="http://jabber.org/protocol/bytestreams"/>
</iq>
Received :
<iq id="018vq-249" to="sender@mydomain.com/Spark 2.6.3" from="proxy.mydomain.com" type="result">
<query xmlns="http://jabber.org/protocol/bytestreams">
<streamhost jid="proxy.mydomain.com" host="mydomain.com" port="7777"/>
</query>
</iq>
Sent :
<iq id="018vq-250" to="receiver@mydomain.com/Smack" type="set">
<query xmlns="http://jabber.org/protocol/bytestreams" sid="jsi_4357088093390871541" mode="tcp">
<streamhost jid="sender@mydomain.com/Spark 2.6.3" host="192.168.1.201" port="7777"/>
<streamhost jid="proxy.mydomain.com" host="mydomain.com" port="7777"/>
</query>
</iq>
Received :
<iq id="018vq-250" to="sender@mydomain.com/Spark 2.6.3" from="receiver@mydomain.com/Smack" type="error">
<error code="-1" type="CANCEL">
<item-not-found xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/>
<text xmlns="urn:ietf:params:xml:ns:xmpp-stanzas" xml:lang="en">Could not establish socket with any provided host</text>
</error>
</iq>
Sent :
<iq id="018vq-251" to="receiver@mydomain.com/Smack" type="set">
<open xmlns="http://jabber.org/protocol/ibb" block-size="4096" sid="jsi_4357088093390871541" stanza="iq"/>
</iq>
sender端收到error IQ后,sender再次向receiver发送IQ文件传输协商流,但此iq后没有收到receiver端的iq
此外,我正在使用以下 smack 库:
compile 'org.igniterealtime.smack:smack-android:4.1.1'
compile 'org.igniterealtime.smack:smack-core:4.1.1'
compile 'org.igniterealtime.smack:smack-tcp:4.1.1'
compile 'org.igniterealtime.smack:smack-extensions:4.1.1'
我得到 solution.The 问题是 smack sdk。
Smack 在文件传输实现中有一些错误:在我的例子中,发起者提供字节流和 ibb 方法,响应者接受这两种(这是错误的)方法。
(参考:@vitalyster 在这里回答Getting ExecutionException on receiving file using asmack in Android)
它应该只接受一个。 因此,在创建 FileNegotiator 时,我只提供了一个流:
FileTransferNegotiator fileTransferNegotiator = FileTransferNegotiator.getInstanceFor(xmppTcpConnection);
FileTransferNegotiator.IBB_ONLY = true;
现在文件传输工作正常。
谢谢大家