xmpp协议,smack包连接不上openfire

发布于 2021-11-23 14:37:50 字数 1857 浏览 891 评论 2

如题,这是异常信息

javax.net.ssl.SSLException: Received fatal alert: unexpected_message
 at com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Alerts.java:190)
 at com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Alerts.java:136)
 at com.sun.net.ssl.internal.ssl.SSLSocketImpl.recvAlert(SSLSocketImpl.java:1682)
 at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:932)
 at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1112)
 at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1139)
 at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1123)
 at org.jivesoftware.smack.XMPPConnection.proceedTLSReceived(XMPPConnection.java:806)
 at org.jivesoftware.smack.PacketReader.parsePackets(PacketReader.java:267)
 at org.jivesoftware.smack.PacketReader.access$000(PacketReader.java:43)
 at org.jivesoftware.smack.PacketReader$1.run(PacketReader.java:70)
org.jivesoftware.smack.XMPPConnection@1f6ba0f
d7919a3d
No response from the server.:
 at org.jivesoftware.smack.NonSASLAuthentication.authenticate(NonSASLAuthentication.java:73)
 at org.jivesoftware.smack.SASLAuthentication.authenticate(SASLAuthentication.java:352)
 at org.jivesoftware.smack.XMPPConnection.login(XMPPConnection.java:203)
 at org.jivesoftware.smack.Connection.login(Connection.java:348)
 at com.chinacreator.imweb.util.SmackXMPPTest.methed(SmackXMPPTest.java:400)
 at com.chinacreator.imweb.util.SmackXMPPTest.main(SmackXMPPTest.java:410)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

瑾兮 2021-11-28 01:40:44

是JDK版本问题= = 改成1.8的JDK就好了

岁月打碎记忆 2021-11-24 03:17:45
import org.jivesoftware.smack.AbstractXMPPConnection;
import org.jivesoftware.smack.ConnectionConfiguration;
import org.jivesoftware.smack.chat.Chat;
import org.jivesoftware.smack.chat.ChatManager;
import org.jivesoftware.smack.chat.ChatMessageListener;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.packet.Presence;
import org.jivesoftware.smack.tcp.XMPPTCPConnection;
import org.jivesoftware.smack.tcp.XMPPTCPConnectionConfiguration;

import javax.net.ssl.SSLContext;
import java.security.SecureRandom;

public class testSmack2 {
//host 172.16.9.88
    //serviceName  	sun-d601bacdc00
    public static void main(String[] args) throws Exception {
        //SSLContext sc = SSLContext.getInstance();

        XMPPTCPConnectionConfiguration config = XMPPTCPConnectionConfiguration.builder()
                .setUsernameAndPassword("ding", "123456")
                .setServiceName("sun-d601bacdc00")
                .setHost("172.16.9.88")
                .setPort(5222).setSecurityMode(ConnectionConfiguration.SecurityMode.disabled).setResource("work").build();


        AbstractXMPPConnection conn1 =new XMPPTCPConnection(config);
        conn1.connect();
        conn1.login();
        System.out.println(conn1.getHost());
        System.out.println(conn1.isConnected());
        System.out.println(conn1.getUser());


        Chat chat = ChatManager.getInstanceFor(conn1).createChat("xiaoming@sun-d601bacdc00");

        chat.addMessageListener(new ChatMessageListener() {
            public void processMessage(Chat chat, Message message) {
                System.out.println(message);
            }
        });
        while (true) {
            chat.sendMessage("lalalal");
            Thread.sleep(5000);
        }
    }
}

以上代码在我这是可以发送消息的

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文