Android的拍击4.1.1文件Transfering,错误无法建立套接字错误、文件、Android、Transfering

2023-09-07 09:49:12 作者:北陌离歌

我想在我的Andr​​oid应用程序与咂嘴库4.1.1发送文件,虽然我有一些错误,这样做。问题是,我不知道为什么它只是将文件发送到设备,但在那之后它不会让我送别人,别人不能发送给其他人要么,比如我第一次开了一个监听器用一台设备,该设备可以和仍然可以发送文件只是一个设备(第一,它发送的),但接收无法之一,该文件似乎到达,但以0数据也许它没有到达,只是当到达什么导致错误我不知道,但过了一段时间我不知道,如果连接或断开的东西,我可以与任何其它设备发送文件,但不与其它,只有一个。和其他人得到这个错误:

I am trying to send files over my android app with smack library 4.1.1, though i am having some errors to do so. The thing is that i don't know why it just sends the files to a device but after that it doesn't let me to send to others and others can't send to others either, for example the first time i opened a listener with one device, that device could and can still send files just to one device (the first that it sent) but the one that receives can not, the file seems to arrive but with 0 data or maybe it doesn't arrive and just when arrives something causes error i am not sure but after a while i don't know if the connection or something breaks and i can send files with any other device but not with another, just one. and the others gets this error:

我也用火花试验,我可以完全从火花,即使当我将文件发送到火花呢接收文件显示了火花也错误。

I also test it with spark and i can receive files perfectly from spark even though when i send a file to spark it shows error on spark also.

日志

    06-28 17:57:54.430    3394-3758/com.example.example D/SMACK﹕ SENT (0): <iq to='example.com' id='36V0P-179' type='get'><query xmlns='http://jabber.org/protocol/disco#items'></query></iq>
    06-28 17:57:54.463    3394-3759/com.example.example D/SMACK﹕ RECV (0): <iq type="result" id="36V0P-179" from="example.com" to="+10000000000@example.com/Example"><query xmlns="http://jabber.org/protocol/disco#items"><item jid="pubsub.example.com" name="Publish-Subscribe service"/><item jid="proxy.example.com" name="Socks 5 Bytestreams Proxy"/><item jid="conference.example.com" name="Public Chatrooms"/></query></iq>
    06-28 17:57:54.464    3394-3758/com.example.example D/SMACK﹕ SENT (0): <iq to='pubsub.example.com' id='36V0P-181' type='get'><query xmlns='http://jabber.org/protocol/disco#info'></query></iq>
    06-28 17:57:54.485    3394-3759/com.example.example D/SMACK﹕ RECV (0): <iq type="result" id="36V0P-181" from="pubsub.example.com" to="+10000000000@example.com/Example"><query xmlns="http://jabber.org/protocol/disco#info"><identity category="pubsub" name="Publish-Subscribe service" type="service"/><feature var="http://jabber.org/protocol/pubsub"/><feature var="http://jabber.org/protocol/pubsub#access-open"/><feature var="http://jabber.org/protocol/pubsub#collections"/><feature var="http://jabber.org/protocol/pubsub#config-node"/><feature var="http://jabber.org/protocol/pubsub#create-and-configure"/><feature var="http://jabber.org/protocol/pubsub#create-nodes"/><feature var="http://jabber.org/protocol/pubsub#delete-nodes"/><feature var="http://jabber.org/protocol/pubsub#get-pending"/><feature var="http://jabber.org/protocol/pubsub#instant-nodes"/><feature var="http://jabber.org/protocol/pubsub#item-ids"/><feature var="http://jabber.org/protocol/pubsub#meta-data"/><feature var="http://jabber.org/protocol/pubsub#modify-affiliations"/><feature var="http://jabber.org/protocol/pubsub#manage-subscriptions"/><feature var="http://jabber.org/protocol/pubsub#multi-subscribe"/><feature var="http://jabber.org/protocol/pubsub#outcast-affiliation"/><feature var="http://jabber.org/protocol/pubsub#persistent-items"/><feature var="http://jabber.org/protocol/pubsub#presence-notifications"/><feature var="http://jabber.org/protocol/pubsub#publish"/><feature var="http://jabber.org/protocol/pubsub#publisher-affiliation"/><feature var="http://jabber.org/protocol/pubsub#purge-nodes"/><feature var="http://jabber.org/protocol/pubsub#retract-items"/><feature var="http://jabber.org/protocol/pubsub#retrieve-affiliations"/><feature var="http://jabber.org/protocol/pubsub#retrieve-default"/><feature var="http://jabber.org/protocol/pubsub#retrieve-items"/><feature var="http://jabber.org/protocol/pubsub#retrieve-subscriptions"/><feature var="http://jabber.org/protocol/pubsub#subscribe"/><feature var="http://jabber.org/protocol/pubsub#subscription-options"/><feature var="http://jabber.org/protocol/disco#info"/></query></iq>
    06-28 17:57:54.486    3394-3758/com.example.example D/SMACK﹕ SENT (0): <iq to='proxy.example.com' id='36V0P-183' type='get'><query xmlns='http://jabber.org/protocol/disco#info'></query></iq>
    06-28 17:57:54.501    3394-3759/com.example.example D/SMACK﹕ RECV (0): <iq type="result" id="36V0P-183" from="proxy.example.com" to="+10000000000@example.com/Example"><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>
    06-28 17:57:54.502    3394-3758/com.example.example D/SMACK﹕ SENT (0): <iq to='conference.example.com' id='36V0P-185' type='get'><query xmlns='http://jabber.org/protocol/disco#info'></query></iq>
    06-28 17:57:54.518    3394-3759/com.example.example D/SMACK﹕ RECV (0): <iq type="result" id="36V0P-185" from="conference.example.com" to="+10000000000@example.com/Example"><query xmlns="http://jabber.org/protocol/disco#info"><identity category="conference" name="Public Chatrooms" type="text"/><identity category="directory" name="Public Chatroom Search" type="chatroom"/><feature var="http://jabber.org/protocol/muc"/><feature var="http://jabber.org/protocol/disco#info"/><feature var="http://jabber.org/protocol/disco#items"/><feature var="jabber:iq:search"/><feature var="http://jabber.org/protocol/rsm"/></query></iq>
    06-28 17:57:54.523    3394-3758/com.example.example D/SMACK﹕ SENT (0): <iq to='proxy.example.com' id='36V0P-187' type='get'><query xmlns='http://jabber.org/protocol/bytestreams'/></iq>
    06-28 17:57:54.537    3394-3759/com.example.example D/SMACK﹕ RECV (0): <iq type="result" id="36V0P-187" from="proxy.example.com" to="+10000000000@example.com/Example"><query xmlns="http://jabber.org/protocol/bytestreams"><streamhost jid="proxy.example.com" host="198.105.244.228" port="7777"/></query></iq>
    06-28 17:57:54.539    3394-3758/com.example.example D/SMACK﹕ SENT (0): <iq to='+11111111111@example.com/Example' id='36V0P-189' type='set'><query xmlns='http://jabber.org/protocol/bytestreams' sid='jsi_3989032673038256169' mode='tcp'><streamhost jid='+10000000000@example.com/Example' host='fe80::5054:ff:fe12:3456%eth0' port='7777'/><streamhost jid='+10000000000@example.com/Example' host='10.0.2.15' port='7777'/><streamhost jid='proxy.example.com' host='198.105.244.228' port='7777'/></query></iq>
    06-28 17:57:59.564    3394-3759/com.example.example D/SMACK﹕ RECV (0): <iq type="get" id="843-84" from="example.com" to="+10000000000@example.com/Example"><ping xmlns="urn:xmpp:ping"/></iq>
    06-28 17:57:59.566    3394-3758/com.example.example D/SMACK﹕ SENT (0): <iq to='example.com' id='843-84' type='result'></iq>
    06-28 17:58:01.304    3394-3759/com.example.example D/SMACK﹕ RECV (0): <iq to="+10000000000@example.com/Example" id="36V0P-189" type="error" from="+11111111111@example.com/Example"><error 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>
    06-28 17:58:01.308    3394-3758/com.example.example D/SMACK﹕ SENT (0): <iq to='+11111111111@example.com/Example' id='36V0P-193' type='set'><open xmlns='https://m.xsw88.com/allimgs/daicuo/20230907/4957.png.jpg");
        Log.e("FILENAMEing file", "to " + Username);

        FileTransferManager manager = FileTransferManager.getInstanceFor(connection);
        OutgoingFileTransfer transfer = manager.createOutgoingFileTransfer(Username + Example.DOMAIN + "/" + Example.APP_NAME);
        try {
            transfer.sendFile(new File(filePathAndName), "This is a Test!");
        } catch (SmackException e) {
            e.printStackTrace();
        }

    }

接收文件:

公共静态无效setFileTransferListener(AbstractXMPPConnection连接){

public static void setFileTransferListener(AbstractXMPPConnection connection){

    FileTransferManager manager = FileTransferManager.getInstanceFor(connection);
    // Create the listener
    manager.addFileTransferListener(new FileTransferListener() {
        @Override
        public void fileTransferRequest(FileTransferRequest request) {
            IncomingFileTransfer transfer = request.accept();
            try {
                File file = new File(Environment.getExternalStorageDirectory()  + File.separator + Example.DB_FOLDER + File.separator + "myFile22.jpg");
                transfer.recieveFile(file);
            } catch (SmackException | IOException e) {
                e.printStackTrace();
            }
        }
    });
}

我喜欢阅读任何答案或提示。我被困在这2天D:我真的需要帮助:/

I would love to read any answer or hint. I am stuck on this for 2 days D: i really need help :/.

端口转发ofcures就像我说的它与一台设备或先开一个监听器,我认为第一个移动机。

The port is forwarded ofcures like i said it works with one device or the first deviced that open a listener first i think.

推荐答案

我希望这可以帮助任何人,该API工作正常,即使我们需要在我们的Openfire服务器更改一些属性:

I hope this helps anyone, the api works fine even though we need to change some properties in our openfire server:

1.  xmpp.proxy.enabled – true 
2.  xmpp.proxy.port – 7777 (7777 is the default but could be another)
3.  xmpp.proxy.externalip – (host or ip)

在当时它工作得非常好,需要做更多的测试,但是,我错了,请人提供任何其他信息,以解决这个问题。

At the time it is working very well, need to make more tests though, I am wrong please someone provide any other info to fix this.