标签: smack

为什么我无法连接到openfire服务器?

我在使用Smack时尝试连接到Openfire(我已安装在我的计算机上)时遇到了一些麻烦.

    ConnectionConfiguration config = new ConnectionConfiguration("shin-pc" ,5222);
    config.setCompressionEnabled(true);
    config.setSASLAuthenticationEnabled(true); 
    XMPPConnection connection = new XMPPConnection(config);             
    connection.connect();
    connection.login("test", "test");
Run Code Online (Sandbox Code Playgroud)

当我尝试调试或运行时,行中出现了某种错误connect().

连接到localhost的XMPPError:5222:remote-server-error(502)连接到localhost的XMPPError:5222. - 由:java.net.SocketException引起:权限被拒绝.

我已经尝试将主机名切换为"localhost",但它也没有用.

我没有这个XMPP业务的经验,所以我猜这是一个常见的新手问题或类似的东西......

可能是什么问题?我该如何解决这个问题,以便连接成功?

java openfire smack

1
推荐指数
1
解决办法
1万
查看次数

使用Smack将带有Payload的项目发布到Pubsub节点

我正在尝试使用Smack将带有负载的项目发布到pubsub节点,但到目前为止我还没有管理.我创建了节点并设置其配置以提供有效负载(setDeliverPayloads = true).我使用send方法发送带有效负载的项目.

 node.send(new PayloadItem(this.clientNodeName+"*" + System.currentTimeMillis(), new SimplePayload("my book", "books:pubsub:simple", "")));
Run Code Online (Sandbox Code Playgroud)

然而,该项目没有有效载荷.构造的IQ也没有有效载荷.正如我从smack的调试面板中看到的那样

这是由smack构建并发送到pubsub服务(显然没有负载)

<iq id="1ha20-11" to="pubsub.127.0.0.1" type="set">
   <pubsub xmlns="http://jabber.org/protocol/pubsub">
   <publish node="autoIncrement">
       <item id="autoIncrement*1333380921970"/>
   </publish>
  </pubsub>
</iq>
Run Code Online (Sandbox Code Playgroud)

我很感激任何帮助来解决这个问题.当然我仍然可以使用本机IQ消息,但我会尽量避免使用smack API中的PubSubManager.

xmpp openfire publish-subscribe smack whack

1
推荐指数
1
解决办法
2747
查看次数

java.lang.NoClassDefFoundError:org.jivesoftware.smack.XMPPConnection

我正在尝试使用asmack android jar将我的android客户端连接到gmail服务器,但我收到运行时错误NoClassDefFoundError ConnectionConfiguration.我使用以下代码

ConnectionConfiguration config = new ConnectionConfiguration("talk.google.com",5222,"gmail.com");
    XMPPConnection connection= new XMPPConnection(config);
Run Code Online (Sandbox Code Playgroud)

即使我只使用XMPPConnection connection= new XMPPConnection("gmail.com");它仍然会抛出NoClassDefFoundError XMPPConnection.项目中的asmack-android-5.jar文件.我甚至尝试使用不同的smack jar运行此应用程序,但无法成功.没有构建错误但是运行时错误并且在eclipse DDMS中可见.通过da方式我使用eclipse.

我已阅读其他帖子但仍无法解决问题.

android xmpp smack asmack

1
推荐指数
1
解决办法
3810
查看次数

我想在加入群组时禁用检索群聊(MUC)历史记录 - Android

我一直在加入房间时接收群聊历史.更具体地说,每当我加入一个组时,我都会收到我发送给该组的最后一条消息(只有一条消息).我已经尝试了以下方法来禁用它..

  • 根据文档建议,我在加入房间时已经将值'maxchars ='0'与初始状态的历史参数一起传递.
  • 在Web管理页面,转到群聊部分,然后是群聊设置 - >群聊服务属性 - >历史记录设置 - >不显示历史记录

虽然我已经尝试了所有这些可能的方法,但在加入房间时仍然收到历史信息.请注意,我在加入时收到的消息包含延迟延期.如果重要的话

android xmpp openfire smack muc

1
推荐指数
1
解决办法
1736
查看次数

Smack Message.setType()不起作用,类型设置为'chat'

我正在尝试使用Type.headline发送消息

这是我的代码:

  public boolean sendText(Chat chat, String text) {
        Message message = new Message();
        message.setBody(text);
        message.setType(Message.Type.headline);
        message.setPacketID("id123456");
        try {
           chat.sendMessage(message);
           Log.d("TAG", message.toXML().toString());
           return true;
        } catch (SmackException.NotConnectedException e) {}
        return false;
}
Run Code Online (Sandbox Code Playgroud)

但是发送的XML看起来像这样:

<message id='id123456' to='roee@192.168.0.3' type='chat'>
   <body>test message</body>
   <thread>ed108b04-4488-423a-a441-ca95284db6c1</thread>
</message>
Run Code Online (Sandbox Code Playgroud)

如您所见,在XML type ='chat'而不是type ='headline'中.

为什么这样,我该如何改变呢?

xmpp smack asmack

1
推荐指数
1
解决办法
320
查看次数

打字状态Smack 4.1

嘿我正在尝试在另一个人开始写入时获得输入状态,即使它返回一条状态为消息的空消息,但它来自proccessMessage方法.不应该在州改变吗?我没有启用任何PacketProvider,我是否必须这样做,所以这将在stateChanged方法中返回?我将不胜感激任何帮助.

   newChat = chatmanager.createChat(contactUsername + sc.DOMAIN, new ChatStateListener() {
        @Override
        public void stateChanged(Chat chat, ChatState state) {
            if (ChatState.composing.equals(state)) {
               Log.d("Chat State",chat.getParticipant() + " is typing..");
            } else if (ChatState.gone.equals(state)) {
               Log.d("Chat State",chat.getParticipant() + " has left the conversation.");
            } else {
             Log.d("Chat State",chat.getParticipant() + ": " + state.name());
            }
        }

        @Override
        public void processMessage(Chat chat, Message message) {
            System.out.println("Received message: " + message);
        }
   });
Run Code Online (Sandbox Code Playgroud)

日志:

06-15 14:28:47.679    9949-9983/com.example.example I/System.out? Received message: <message to='+931111111111@example.com' from='+930000000000@example.com/Spark 2.6.3' id='AUJG0-42' type='chat'><thread>097uC9</thread><inactive xmlns='http://jabber.org/protocol/chatstates'/></message>
Run Code Online (Sandbox Code Playgroud)

android xmpp smack asmack

1
推荐指数
1
解决办法
2572
查看次数

如何在android中的两个Activity之间传递XMPPTCPConnection对象?

我想传递一个 XMPPTCPConnection 对象,intent.putExtra(...);但不幸的是它不能将我的对象转换为SerializeParcelable喜欢:signInIntent.putExtra("connection", (Serialize) conn);并报告错误:“无法转换XMPPTCPConnectionSerializeParcelable。” 我看到许多类似的问题,并尝试像他们的答案一样做。所以我尝试将对象添加到列表中,然后传递该列表。这是我的第一个活动:

Intent signInIntent = new Intent(LoginActivity.this, MainActivity.class);
ArrayList<XMPPTCPConnection> conn = new ArrayList<XMPPTCPConnection>();
conn.add(connection);
signInIntent.putExtra("connection",  conn);
startActivity(signInIntent);
Run Code Online (Sandbox Code Playgroud)

这是我的第二个活动:

Bundle getData = getIntent().getExtras(); 
List<XMPPTCPConnection> listConn = new ArrayList<>();
listConn = (List<XMPPTCPConnection>) getData.get("connection");
XMPPTCPConnection connection = listConn.get(0);
Run Code Online (Sandbox Code Playgroud)

但这个错误报告:

12-27 18:48:42.919 30358-30358/finalproject.ffisher.com.finalproject E/AndroidRuntime: FATAL EXCEPTION: main
12-27 18:48:42.919 30358-30358/finalproject.ffisher.com.finalproject E/AndroidRuntime: Process: finalproject.ffisher.com.finalproject, PID: 30358
12-27 18:48:42.919 30358-30358/finalproject.ffisher.com.finalproject E/AndroidRuntime: java.lang.RuntimeException: Parcel: unable to marshal value org.jivesoftware.smack.tcp.XMPPTCPConnection@3f8f8920 …
Run Code Online (Sandbox Code Playgroud)

android xmpp smack android-activity

1
推荐指数
1
解决办法
513
查看次数

尝试在Android上使用smack连接openfire时出错

XMPPTCPConnectionConfiguration.Builder configBuilder =  XMPPTCPConnectionConfiguration.builder();
    configBuilder.setUsernameAndPassword("test", "test");
    configBuilder.setResource("test");
    configBuilder.setServiceName("37.139.26.142");
    configBuilder.setHost("37.139.26.142");
    configBuilder.setPort(5222);
    configBuilder.setSendPresence(true);
    configBuilder.setDebuggerEnabled(true);
    configBuilder.setSecurityMode(XMPPTCPConnectionConfiguration.SecurityMode.required );
    SASLMechanism mechanism = new SASLDigestMD5Mechanism();
    SASLAuthentication.registerSASLMechanism(mechanism);
    SASLAuthentication.blacklistSASLMechanism("SCRAM-SHA-1");
    SASLAuthentication.unBlacklistSASLMechanism("DIGEST-MD5");
    AbstractXMPPConnection connection = new XMPPTCPConnection(configBuilder.build());
    try {
        connection.connect();
    } catch (SmackException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } catch (XMPPException e) {
        e.printStackTrace();
    }
    try {
        connection.login();
    } catch (XMPPException e) {
        e.printStackTrace();
    } catch (SmackException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
Run Code Online (Sandbox Code Playgroud)

我正在尝试握手我的Android应用程序和我的openfire服务器(在ubuntu上工作).但我不能.我没有任何失败或什么.什么都没发生.那感觉很糟糕.

android chat openfire smack

1
推荐指数
1
解决办法
3278
查看次数

Android/Eclipse错误 - "无法找到类'org.jivesoftware.smack.ConnectionConfiguration',从方法引用"

这是我第一次使用Android/Java.我试图运行这个基本代码,我不断收到以下错误:

"找不到类'org.jivesoftware.smack.ConnectionConfiguration',从方法中引用"

  • 我的代码:

    package message.pack;
    import org.jivesoftware.smack.ConnectionConfiguration;
    import org.jivesoftware.smack.XMPPConnection;
    import org.jivesoftware.smack.XMPPException;
    
    import android.app.Activity;
    import android.os.Bundle;
    
    public class ThesimpleigniteandroidActivity extends Activity {
        /** Called when the activity is first created. */
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
    
        }
    
                  public static void main(String[] args) {
                  ConnectionConfiguration conf = new     ConnectionConfiguration("jabber.com",5222);
                  XMPPConnection connection = new XMPPConnection(conf);
                      try {
                      connection.connect();
                      connection.login("myusername", "mypassword");
                      } catch (XMPPException e) {
                      e.printStackTrace();
                      } finally {
                              connection.disconnect();
                      }
                      }
                      }
    
    Run Code Online (Sandbox Code Playgroud)

我正在使用此页面中的smack.jar:

http://vidorsolutions.blogspot.com/2011/01/writing-xmppjabber-chat-application-for.html?m=1

谁能告诉我我做错了什么?

java eclipse android smack

0
推荐指数
1
解决办法
9436
查看次数

如何实现Smack 4.1.0,ConnectionConfiguration.Builder类?

smack 4.1.0库有变化,有人能告诉我如何实现ConnectionConfiguration.Builder<B extends ConnectionConfiguration.Builder<B,C>,C >类吗?

java xmpp smack

0
推荐指数
1
解决办法
3059
查看次数

如何在聊天应用程序中发送媒体内容?

我正在设计一个使用ejabberd作为XMPP服务器和Smack 4.1 API的Android聊天应用程序.

我的要求是在聊天窗口中发送内嵌图像,地图和视频.我意识到,在性能方面,通过XMPP Server(ejabberd)发送媒体内容并不是一个好主意.

我需要专家建议如何继续在聊天窗口中发送内联媒体内容?

提前致谢.

chat xmpp ejabberd smack server

0
推荐指数
1
解决办法
1590
查看次数

文件传输不工作smack 4.1 android

目前我正在玩新的Smack 4.1,它提供对android的全面支持.发送和接收消息没问题,工作正常.但现在,我被困在发送和接收文件.例如:

发送文件

public void sendFile(String fileName,String to){

        if(transferManager==null) {
            transferManager = FileTransferManager.getInstanceFor(mConnection);

        }


        OutgoingFileTransfer transfer = transferManager.createOutgoingFileTransfer(to);

        try {

            transfer.sendFile(new File(fileName), "This is a Test!");
        } catch (SmackException e) {
            e.printStackTrace();
        }
    }
Run Code Online (Sandbox Code Playgroud)

接收文件

 public void setReceiveFileListener(){


        if(transferManager==null) {
            transferManager = FileTransferManager.getInstanceFor(mConnection);
        }
        transferManager.addFileTransferListener(new FileTransferListener() {
            @Override
            public void fileTransferRequest(FileTransferRequest request) {
                IncomingFileTransfer transfer = request.accept();

                try {
                    File file = new File(Environment.getExternalStorageDirectory()  + File.separator +"TEST"+File.separator+ "new.txt");
                    transfer.recieveFile(file);

                } catch (SmackException | IOException e) {
                    e.printStackTrace();

                }
            }
        }); …
Run Code Online (Sandbox Code Playgroud)

android file-transfer smack

0
推荐指数
1
解决办法
2525
查看次数

使用aSmack客户端映射Openfire自定义插件

我是XMPP的新手,请原谅我,如果这个问题听起来很愚蠢.我想创建一个自定义插件并将其映射到Android上的aSmack客户端.我正在尝试应用我的Web服务知识,但我没有赢.所以请引导我的思路走向最好的方法,一个例子将非常有用.Thanx提前.

java android xmpp openfire smack

0
推荐指数
1
解决办法
803
查看次数