2012-06-13 52 views
0

我使用Jabber Smack API創建了一個聊天應用程序。我正在成功接收文件(來自另一個名爲「Gajim」的應用程序),但是我的上傳僅在幾秒鐘內失敗。在「協商」傳輸狀態之後,我收到「錯誤」狀態。在Smack中上傳文件時出錯

我通過提供「完全合格」的jabber ID來糾正這個錯誤,但是現在當我接受來自另一個(Gajim)客戶端的轉移後,轉移無限期地停留在「協商流」上。

我有以下代碼爲我的SwingWorker類:​​

OutgoingFileTransfer transfer; 

    @Override 
    public Void doInBackground() { 

     transfer = manager.createOutgoingFileTransfer("[email protected]/Gajim"); 
     File uploadFile = fileChooser.getSelectedFile(); 
     try { 
      transfer.sendFile(uploadFile, "test"); 
     } catch (XMPPException ex) { 
      System.out.println("sendFile Error"); 
      ex.printStackTrace(); 
     } 
     while (!transfer.isDone()) { 
      if (transfer.getStatus().equals(Status.error)) { 
       transferLabel.setText("ERROR!!! " + transfer.getError()); 
      } else { 
       transferLabel.setText("Uploading File: " + uploadFile.getName() 
         + " STATUS: " + transfer.getStatus()); 
       fileProgressBar.setValue((int) (100 * transfer.getProgress())); 
      } 
      try { 
       Thread.sleep(500); 
      } catch (InterruptedException ex) { 
       System.out.println("thread.sleep error"); 
       ex.printStackTrace(); 
      } 
     } 

     return null; 
    } 

回答

0

錯誤是在Jabber服務器。 使用openfire服務器解決了我所有的問題

+0

你覺得這個代碼能使用moongoose im服務器嗎? –