2012-05-01 5 views
8

問題:XMPPとOpenFire Server経由でアンドロイドアプリに送信されたファイルを受信できません。私は正常にファイルを送信することができます。(ファイルはスパークを経由して送信された場合XMPPとOpenFireでAndroidファイル転送が動作しない

connConfig = new ConnectionConfiguration("beta.myCompany.co.uk", 5222); 
    connConfig.setSASLAuthenticationEnabled(true); 
    try { 
     connect("username", "password"); 
    } catch (Exception e) { 
     e.printStackTrace(); 
    } 

    ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(connection); 
    if(sdm == null) 
     sdm = new ServiceDiscoveryManager(connection); 

    fileTransferManager = new FileTransferManager(connection); 
    FileTransferNegotiator.setServiceEnabled(connection, true); 

fileTransferManager.addFileTransferListener(new FileTransferListener() { 
    @Override 
    public void fileTransferRequest(FileTransferRequest request) { 
     IncomingFileTransfer transfer = request.accept(); 
     try { 
      FileOutputStream fos = openFileOutput(request.getFileName(), Context.MODE_PRIVATE); 
      InputStream stream = transfer.recieveFile();//THIS FAILS! 
      fos.write(IOUtils.toByteArray(stream)); 
      fos.close();  
     } catch (Exception e) { 
      e.printStackTrace(); 
     } 
} 

エラー:私は使用していますasmackジャーはasmack-JSE-buddycloud-2010.12.11.jar

コードある

実行中のエラー: - 原因: java.util.concurrent.ExecutionException:ファイルからの応答がありません転送開始剤:(ファイルはAdiumのを経由して送信された場合

エラー:

java.util.concurrent.ExecutionException:アイテム - :任意の提供ホストとソケット を確立できませんでした見つからない(404)ソケットを確立できませんでした

エラー(ファイルは私のアプリの別のインスタンスを経由して送信された場合):実行中の

エラー: - によって引き起こさ: java.util.concurrent.ExecutionException: - によって引き起こさ:いいえ応答

マイログ:リモートクライアントからの(スパークからファイルを受信しようとすると)

私がこのエラーを送信していますことが表示されます! (受け取っていない)。これはなぜでしょうか?

> 05-01 12:49:36.013: I/System.out(1000): 12:49:35 PM SENT (1093411736): 
> <iq id="791-6222" to="beta.myCompany.co.uk" 
> from="[email protected]/BAM-1918973529" type="error"><error 
> code="501" type="CANCEL"><feature-not-implemented 
> xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/></error></iq> 

エクストラログ

05-01 14:46:06.133: I/System.out(1370): 02:46:06 PM RCV (1093401112): <iq id="eRi5A-72" to="[email protected]/BAM-1755858011" from="[email protected]/Spark 2.6.3" type="set"><si xmlns="http://jabber.org/protocol/si" id="jsi_5991130279184702850" profile="http://jabber.org/protocol/si/profile/file-transfer"><file xmlns="http://jabber.org/protocol/si/profile/file-transfer" name="Test.rtf" size="318"><desc>Sending file</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> 
05-01 14:46:08.283: I/System.out(1370): 02:46:08 PM SENT (1093401112): <iq id="eRi5A-72" to="[email protected]/Spark 2.6.3" from="[email protected]/BAM-1755858011" 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></field></x></feature></si></iq> 
05-01 14:46:08.312: I/System.out(1370): 02:46:08 PM RCV (1093401112): <iq id="eRi5A-73" to="[email protected]/BAM-1755858011" type="get" from="[email protected]/Spark 2.6.3"><query xmlns="http://jabber.org/protocol/disco#info"/></iq> 
05-01 14:46:14.352: W/System.err(1370): Error in execution: 
05-01 14:46:14.352: W/System.err(1370): -- caused by: java.util.concurrent.ExecutionException: No response from file transfer initiator:[ 
[ERROR LOG IS HERE] 
05-01 14:46:14.732: I/System.out(1370): 02:46:14 PM SENT (1093401112): <iq id="eRi5A-73" to="[email protected]/Spark 2.6.3" type="result"><query xmlns="http://jabber.org/protocol/disco#info"><identity category="client" name="Smack" type="pc"/><feature var="http://jabber.org/protocol/caps"/><feature var="http://jabber.org/protocol/bytestreams"/><feature var="http://jabber.org/protocol/si/profile/file-transfer"/><feature var="http://jabber.org/protocol/si"/><feature var="http://jabber.org/protocol/ibb"/></query></iq> 
05-01 14:46:14.773: I/System.out(1370): 02:46:14 PM RCV (1093401112): <iq id="eRi5A-77" to="[email protected]/BAM-1755858011" type="set" from="[email protected]/Spark 2.6.3"><query xmlns="http://jabber.org/protocol/bytestreams" sid="jsi_5991130279184702850" mode="tcp"><streamhost jid="[email protected]/Spark 2.6.3" host="10.95.104.25" port="7777"/><streamhost jid="proxy.beta.myCompany.co.uk" host="127.0.1.1" port="7777"/></query></iq> 
05-01 14:46:29.783: I/System.out(1370): 02:46:29 PM RCV (1093401112): <iq type="get" id="537-7113" from="beta.myCompany.co.uk" to="[email protected]/BAM-1755858011"><ping xmlns="urn:xmpp:ping"/></iq> 
05-01 14:46:29.843: I/System.out(1370): 02:46:29 PM SENT (1093401112): <iq id="537-7113" to="beta.myCompany.co.uk" from="[email protected]/BAM-1755858011" type="error"><error code="501" type="CANCEL"><feature-not-implemented xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/></error></iq> 
+0

両側から501エラーが興味深いであろう前に、XMPPはスタンザ。 – Flow

+0

あなたの応答フローをありがとう。私は501より前からアプリからのログを追加しました。 –

+0

こんにちは@AndyAあなたは私を助けてくれますか?http://stackoverflow.com/questions/11666963/file-is-not-being-transferred-in-smack- api – juned

答えて

3

使用

transfer.receiveFile(myLocalFile); 

代わりの

InputStream stream = transfer.receive(); 

あなたはPacketReaderスレッドをブロックしています。最初の方法は、転送されるファイルの部分を構成する特定のパケットを読み取るための独自のスレッドを生成します。 2番目の方法を使用する場合は、実際のファイルの読み書きを行うために独自のスレッドを生成する必要があります。

+0

これは動作します。次のコードを使用してファイルを読み取ることができます。 IncomingFileTransfer transfer = request.accept(); transfer.recieveFile(新しいファイル(getExternalFilesDir(null)、transfer.getFileName()));文字列; BufferedReader br = new BufferedReader(新しいFileReader(新しいファイル(getExternalFilesDir(null)、transfer.getFileName()))); while((line = br.readLine())!= null)System.out.println(line); –

+1

また、あなたのマニフェストファイルに以下の権限が必要です... \t

+0

私は同じ問題に直面しています。 http://stackoverflow.com/q/28271210/4358880)問題を解決するのに役立ちます –

0

私は他のユーザーコードの一部copy_pasteで、ジャワの簡単なプログラムを作成しましたが、+ポイントは、それが動作していることで、私はあなたがTXTを送ることができますLocalHost - SPark client - javaProgram

ワット/このBを試してみました。openFile User Sectionで作成した他のユーザーにファイルを送信します。

注:Xmpp.test クラスの詳細については、必要に応じて変更してください。

Download Xmpp File Transfer "Java Code" From Here

+0

私はこれを試しましたが、この行はいつも励ましています: '(transfer.getStatus()。equals(Status.refused) \t \t \t \t || transfer.getStatus()。等号(Status.error) \t \t \t \t || transfer.getStatus()。等号(Status.cancelled)){ \t \t \tのSystem.out \t \t \t \t \t .println( "キャンセルされたキャンセルエラー" + transfer.getError()); 'は、送信が失敗したと見なしても、送信に失敗しました。私はなぜこのエラーが発生し続けるのか分からない。 –

関連する問題