Smack API,connect() 异常

发布于 2025-01-03 13:39:37 字数 1877 浏览 2 评论 0原文

我正在尝试连接到我公司的 XMPPServer 并收到以下异常:

java.io.EOFException: input contained no data
at org.xmlpull.mxp1.MXParser.fillBuf(MXParser.java:3003)
at org.xmlpull.mxp1.MXParser.more(MXParser.java:3046)
at org.xmlpull.mxp1.MXParser.parseProlog(MXParser.java:1410)
at org.xmlpull.mxp1.MXParser.nextImpl(MXParser.java:1395)
at org.xmlpull.mxp1.MXParser.next(MXParser.java:1093)
at org.jivesoftware.smack.PacketReader.parsePackets(PacketReader.java:325)
at org.jivesoftware.smack.PacketReader.access$000(PacketReader.java:43)
at org.jivesoftware.smack.PacketReader$1.run(PacketReader.java:70)

我的代码非常基本...

System.setProperty("smack.debugEnabled", "true");
XMPPConnection.DEBUG_ENABLED = true;
ConnectionConfiguration config = new ConnectionConfiguration("xxx", 5223);
config.setSecurityMode(SecurityMode.enabled);
config.setSASLAuthenticationEnabled(true);
config.setDebuggerEnabled(true);
config.setCompressionEnabled(false);
XMPPConnection connection = new XMPPConnection(config);
connection.connect();

我做错了什么?
Smack 调试窗口中的“原始发送数据包”似乎显示了正确的 xml 流:

<stream:stream to="xxx" xmlns="jabber:client" xmlns:stream="http://etherx.jabber.org/streams" version="1.0">
<presence id="3347O-0" type="unavailable"></presence>
</stream:stream>

---- 更新 ----

我发现了问题。
对于 SSL 连接,需要以下代码:

config.setSecurityMode(ConnectionConfiguration.SecurityMode.enabled);
config.setSocketFactory(new DummySSLSocketFactory());

DummySSLSocketFactory 类可以在 Spark 中找到或直接在此处找到:

http://svn.igniterealtime.org/svn/repos/spark/trunk/src/java/org/jivesoftware/spark/util/DummySSLSocketFactory.java

I'm trying to connect to my company XMPPServer and get the following exception:

java.io.EOFException: input contained no data
at org.xmlpull.mxp1.MXParser.fillBuf(MXParser.java:3003)
at org.xmlpull.mxp1.MXParser.more(MXParser.java:3046)
at org.xmlpull.mxp1.MXParser.parseProlog(MXParser.java:1410)
at org.xmlpull.mxp1.MXParser.nextImpl(MXParser.java:1395)
at org.xmlpull.mxp1.MXParser.next(MXParser.java:1093)
at org.jivesoftware.smack.PacketReader.parsePackets(PacketReader.java:325)
at org.jivesoftware.smack.PacketReader.access$000(PacketReader.java:43)
at org.jivesoftware.smack.PacketReader$1.run(PacketReader.java:70)

My code is really basic...

System.setProperty("smack.debugEnabled", "true");
XMPPConnection.DEBUG_ENABLED = true;
ConnectionConfiguration config = new ConnectionConfiguration("xxx", 5223);
config.setSecurityMode(SecurityMode.enabled);
config.setSASLAuthenticationEnabled(true);
config.setDebuggerEnabled(true);
config.setCompressionEnabled(false);
XMPPConnection connection = new XMPPConnection(config);
connection.connect();

What am I doing wrong?
The "Raw Sent Packets" from the Smack Debug window seem to display the right xml flow:

<stream:stream to="xxx" xmlns="jabber:client" xmlns:stream="http://etherx.jabber.org/streams" version="1.0">
<presence id="3347O-0" type="unavailable"></presence>
</stream:stream>

---- UPDATE ----

I found the issue.
For SSL connection the following code is needed:

config.setSecurityMode(ConnectionConfiguration.SecurityMode.enabled);
config.setSocketFactory(new DummySSLSocketFactory());

The DummySSLSocketFactory class can be found in Spark or directly here:

http://svn.igniterealtime.org/svn/repos/spark/trunk/src/java/org/jivesoftware/spark/util/DummySSLSocketFactory.java

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

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

发布评论

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

评论(1

酒浓于脸红 2025-01-10 13:39:37

我发现了这个问题。
对于 SSL 连接,需要以下代码:

config.setSecurityMode(ConnectionConfiguration.SecurityMode.enabled);
config.setSocketFactory(new DummySSLSocketFactory());

您可以使用 DummySSL 类,在 Spark 中也可以找到。

I found the issue.
For SSL connection the following code is needed:

config.setSecurityMode(ConnectionConfiguration.SecurityMode.enabled);
config.setSocketFactory(new DummySSLSocketFactory());

You can use the DummySSL class, which can also be found in Spark.

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