无法使用react-native-xmpp与openfire连接

问题描述 投票:6回答:1

我有一个反应原生的聊天应用程序,我在我的Android手机上使用USB调试运行,我使用OPENFIRE作为聊天服务器。为了与Openfire连接,我正在使用库'react-native-xmpp'。下面是使用react-native-xmpp连接OPENFIRE的代码 -

import XMPP from 'react-native-xmpp';
var JID = '[email protected]';

XMPP.on('error', (message) => console.log('ERROR:' + message));
XMPP.on('loginError', (message) => console.log('LOGIN ERROR:' + message));
XMPP.on('login', (message) => console.log('LOGGED!'));
XMPP.on('connect', (message) => console.log('CONNECTED!'));

XMPP.connect('[email protected]', 'root','RNXMPP.PLAIN','192.168.4.246',5222);
XMPP.message('Hello world!' , JID);

XMPP.disconnect();

我在这里使用的IP是我的本地IP地址。我正在尝试连接到端口5222作为PLAIN连接。但我得到一个错误说

客户端需要SSL / TLS但服务器不支持或不再支持。

我在端口5222检查了OPENFIRE配置。我禁用了加密并启用了加密,但两种情况都没有任何区别。我也尝试连接到端口5223然后错误说

javax.net.ssl.SSLHandshakeException:java.security.cert.CertPathValidatorException:未找到证书路径的信任锚。

我没有上传大量代码,因为我认为错误要么在于库,要么是我不理解的一些网络概念。有没有人知道这里可能出现的问题或任何其他更好的方法吗?

ssl react-native xmpp openfire
1个回答
0
投票

您正面临此错误,因为在react-native-xmpp的java代码中,默认情况下启用安全模式。如果要使用PLAIN文本身份验证,则必须将其关闭。

示例:假设您的本机应用程序名称为TestApp,然后转到以下目录:TestApp / node_modules / react-native-xmpp / android / src / main / java / rnxmpp / service并转到第76行并替换为以下行:

之前:

.setSecurityMode(ConnectionConfiguration.SecurityMode.required);

后:

.setSecurityMode(ConnectionConfiguration.SecurityMode.disabled);

© www.soinside.com 2019 - 2024. All rights reserved.