Help xmpp.js interoperate with Openfire

Hello,

I am the author and maintainer of xmpp.js, a popular multi-platform JavaScript library for XMPP. A user opened an issue about being unable to use xmpp.js with OpenFire.

See https://github.com/xmppjs/xmpp.js/issues/889

I was able to reproduce the issue with starttls and direct tls but not with secure websocket. Here is a small reproduce test case.

I don’t use Openfire myself and I have limited time to dedicate to this, any help would be appreciated.

npm install @xmpp/client
NODE_TLS_REJECT_UNAUTHORIZED=0 node openfire.js
// openfire.js
const { client, xml } = require("@xmpp/client");

const xmpp = client({
  // direct TLS - affected
  // service: "xmpps://localhost:5223",
  // starttls - affected
  service: "xmpp://localhost:5222",
  // plain websocket - not affected
  // service: "ws://localhost:7070/ws",
  // secure websocket - not affected
  // service: "xmpp://localhost:744/ws",
  domain: "localhost",
  resource: "example",
  username: "admin",
  password: "*****",
});

xmpp.on("output", (data) => console.log("output\n", data));
xmpp.on("input", (data) => console.log("input\n", data));
xmpp.on("status", (status) => console.log("status", status));

xmpp.on("error", (err) => {
  console.error(err);
});

xmpp.on("offline", () => {
  console.log("offline");
});

xmpp.on("online", async (address) => {
  console.log("online as", address.toString());
  await xmpp.stop();
});

xmpp.start().catch(console.error);
3 Likes

I’m having the same issue. Has anyone been able to look into this?

After debugging this for a while, I found that disabling TLSv1.3 in Openfire seems to solve the issue. But with TLSv1.3 enabled, it doesn’t work (neither with Java11 nor with Java8, so JVM version doesn’t seem to matter). Hope this might help someone willing to research this :slight_smile:

I think this is a known problem if you are using Openfire with Java 11.

Thanks for the reply! :slight_smile:

Do you have any reference about the problem I could read up on?
I tried using Java 8 yesterday, but it behaved the same.

I managed to find a workaround in the client though. You can refer to my debugging result here:

If there’s a better explanation somewhere on why this happens exactly, I’d be really thankful to learn about it! :slight_smile:

Apologies for being so late to the party, but I believe I might have identified the cause and a potential fix for this.

@sonnyp’s comment that this affects only certain endpoints, but not others, made me suspect the third-party library that we use for exactly those endpoints. We are using Apache MINA for those endpoints.

After discussing the issue within that community, they have asked me to test against a new implementation (as of yet unreleased). Again, using Sonny’s reproduction path, I was able to confirm that the problem seems to be gone when using that updated third party library.

We probably need to update to a new version of MINA to resolve this issue.

I have raised a new ticket to track this change: [OF-2435] - Ignite Realtime Jira

2 Likes