nioc / xmpp-web

Lightweight web chat client for XMPP server
GNU Affero General Public License v3.0
142 stars 20 forks source link

Unble to connect Openfire through xmpp-web #118

Closed etechkuldip closed 7 months ago

etechkuldip commented 7 months ago

Describe the bug

I have been trying to connect Openfire through xmpp-web.

Steps to reproduce

Openfire version : 4.7.5 => Disabled TLS V1.3 under port 5222

image

Registration

image

Run App through from Vue.js => "preview": "vite build && vite preview --port 8080",

image

Expected behavior

At least, I want to see the errors from console, its only showing Error during login.

Relevant log

No response

local.js configuration

// eslint-disable-next-line no-unused-vars, no-var
var config = {
  name: "XMPP web",
  transports: {
    websocket: "xmpp://kuldip-pc:5222", //'wss://chat.domain-web.ltd/xmpp-websocket',
  },
  hasGuestAccess: true,
  hasRegisteredAccess: true,
  anonymousHost: null,
  // anonymousHost: 'anon.domain-xmpp.ltd',
  isTransportsUserAllowed: false,
  hasHttpAutoDiscovery: false,
  resource: "Web XMPP",
  defaultDomain: "kuldip-pc",
  defaultMuc: null,
  // defaultMuc: 'conference.domain-xmpp.ltd',
  isStylingDisabled: false,
  hasSendingEnterKey: false,
  connectTimeout: 5000,
  pinnedMucs: [],
  logoUrl: "",
  guestDescription: "",
};

XMPP-web version

0.10.0

Installation

Build from source

XMPP server(s)

Openfire

Browser(s)

Chrome

Device(s)

desktop

Other information

No response

nioc commented 7 months ago

Hello @etechkuldip

I don't know Openfire but with Prosody there is the cross_domain_websocket parameter that need to be set with the web url (http://localhost:8080/ in case of npm run preview).

can be identified by the 403 HTTP response (GET ws://10.0.0.79:5280/xmpp-websocket) in browser network tab:

HTTP/1.1 403 Forbidden
Date: Sat, 30 Mar 2024 17:23:35 GMT
Content-Length: 401
Connection: Keep-Alive
Content-Type: text/html; charset=utf-8

As it work for me, I ask you to provide a reproducing configuration.

etechkuldip commented 7 months ago

@nioc Thank you for your prompt reply. I comprehend your message, and I will replicate the process after altering my surroundings.

Here is the my new configuration,

var config = { name: "XMPP web", transports: { websocket: "ws://kuldip-pc:5222/ws", }, hasGuestAccess: true, hasRegisteredAccess: true, anonymousHost: null, // anonymousHost: 'anon.domain-xmpp.ltd', isTransportsUserAllowed: false, hasHttpAutoDiscovery: false, resource: "Web-XMPP", defaultDomain: "kuldip-pc", defaultMuc: null, // defaultMuc: 'conference.domain-xmpp.ltd', isStylingDisabled: false, hasSendingEnterKey: false, connectTimeout: 5000, pinnedMucs: [], logoUrl: "", guestDescription: "", };

Now using ws://kuldip-pc:5222/ws , I am getting Server unreachable.

image

I also increase timeout , but still the problem same.

Here is the openfire server ports list

image

I know ,you are not familiar but what should be a port and url to connect ? just help me with url or right connection url

nioc commented 7 months ago

You can have a look to this discussion

nioc commented 7 months ago

Probably something like this (without TLS) : ws://your.openfire.host:7070/ws

etechkuldip commented 7 months ago

@nioc Thanks sir, It connected, but I am getting the below error if I uncheck Plain SASL Mechanism.

image

I want to use wss://kuldip-pc:7443/ws/ but it is not connecting. I don't have to use Plain SASK Mechanism for security reasons. Can you please guide me for WSS?

nioc commented 7 months ago

The auth mechanism allowed by the xmpp.js library is only PLAIN. But it is not a problem using TLS (as the connection is secured).

Does your certificate is OK? What the console/network tab says using the secure port (wss://…:7443)? May be using https scheme instead of wss. At least using a proxy (Apache or Nginx) may solve issue.

etechkuldip commented 7 months ago

@nioc Here is the error image

nioc commented 7 months ago

And what about network tab for the WS request?

etechkuldip commented 7 months ago

Nothing showing image

nioc commented 7 months ago

In the header tab?

etechkuldip commented 7 months ago

image

nioc commented 7 months ago

Strange behavior 😞

I do not think it is a bug in the app or library (because it works without TLS in your setup and with TLS in mine).

So I think about 2 leads:

etechkuldip commented 7 months ago

@nioc Allow me some time, I will update you on what you suggest

etechkuldip commented 7 months ago

image

nioc commented 7 months ago

Looks like a certificate issue 😉 Maybe you can force your browser to trust it (I'm not a cert expert). I suggest using a let's encrypt cert for your production.

etechkuldip commented 7 months ago

Ohh, thanks, Do you know how to fix it or reference, any link ? I am not familiar with it,

nioc commented 7 months ago

For the cert creation: https://certbot.eff.org/ For use in OpenFire (just Googled 😆): https://meetrix.io/blog/xmpp/openfire_ssl.html

I close the issue but feel free to continue discussion.

guusdk commented 5 months ago

Openfire now has a plugin that lets you add XMPP Web automatically. You could use that, or use it for inspiration on how to configure a stand-alone instance of XMPP web.

More details on Openfire's plugin: https://discourse.igniterealtime.org/t/new-openfire-plugin-xmpp-web/