processone / ejabberd

Robust, Ubiquitous and Massively Scalable Messaging Platform (XMPP, MQTT, SIP Server)
https://www.process-one.net/en/ejabberd/
Other
6.06k stars 1.51k forks source link

host-unknown error wth hosts configuration as * #4004

Closed pinanklakhani closed 1 year ago

pinanklakhani commented 1 year ago

Chat application is as module in my platform and users with any email domain can use chat module after login. I am using user's email as jid and kept hosts value as * but in that case its giving following error.

ejabberd.yml

hosts:
  - "*"
  - localhost

error

2023-03-02 10:51:11.890583+05:30 [notice] <0.2932.0> (websocket|<0.2931.0>) Send XML on stream = <<"<stream:error><host-unknown xmlns='urn:ietf:params:xml:ns:xmpp-streams'/></stream:error>">>
licaon-kter commented 1 year ago

You should define an actual host, wildcard is not a valid value :)

pinanklakhani commented 1 year ago

Ok but users will be dynamic for me with different domains in their email

licaon-kter commented 1 year ago

Then setup hosts for those domains, you need to provide certs for those domains too.

pinanklakhani commented 1 year ago

@licaon-kter Practically it is not possible as there can be n number of domains as my platform is for enterprises they can signup any time and use

licaon-kter commented 1 year ago

When they sign up you add another domain in hosts:, put the domain certs in the proper place and run ejabberdctl reload_config to be able to serve it.

You can automate this...

pinanklakhani commented 1 year ago

@licaon-kter Okay. Let me check for other ways as well

badlop commented 1 year ago

Chat application is as module in my platform and users with any email domain can use chat module after login. I am using user's email as jid and kept hosts value as * but in that case its giving following error.

Umm, try this idea:

For example, if you configure:

hosts:
  - yourdomain.com

Tell your users to define their XMPP JID like this:

Let's imagine my email address is john@gmail.com. I can register an account in your server with

This works in ejabberd (and any other XMPP server), and works with all Jabber/XMPP clients:

ejabberdctl register john#gmail.com yourdomain.com asd
User john#gmail.com@yourdomain.com successfully registered

And login:

2023-03-02 14:01:01.472163+01:00 [info] (<0.1297.0>)
  Accepted connection [::ffff:127.0.0.1]:36137 -> [::ffff:127.0.0.1]:5222
2023-03-02 14:01:02.316141+01:00 [info] (tls|<0.1297.0>)
  Accepted c2s DIGEST-MD5 authentication for john#gmail.com@yourdomain.com by mnesia backend from ::ffff:127.0.0.1
2023-03-02 14:01:02.384197+01:00 [info] (tls|<0.1297.0>)
  Opened c2s session for john#gmail.com@yourdomain.com/tkabber
prefiks commented 1 year ago

Standard escape for @ in jid is \40 (so it would be jim\40gmail.com) - this is defined in https://xmpp.org/extensions/xep-0106.html, it's even possible that some client will do that for you when you use '@' in username.

pinanklakhani commented 1 year ago

Thanks @badlop I moved with the similar type of implementation where i took users unique id as username and appended my domain.