Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IS mod_rest compatible with ejabberd 24.2.0? #334

Open
AlanChatflix opened this issue Apr 29, 2024 · 10 comments
Open

IS mod_rest compatible with ejabberd 24.2.0? #334

AlanChatflix opened this issue Apr 29, 2024 · 10 comments

Comments

@AlanChatflix
Copy link

I installed the new ejabberd 24.2.0, then installed mod_rest. It installed correctly.
But whenever I try to add it on ejabberd.yml:
modules:
mod_rest: {}

it fails. doesn't matter how I add it, it fails to reload or restart ejabberd. Why?

@badlop
Copy link
Member

badlop commented Apr 29, 2024

Yes, it should work. It works compiling ejabberd manualy, and also using a container image:

For this test, I'll use the ejabberd container image. I'll start it in interactive mode so I get log messages immediately:

$ podman run --name ejabberd -it -p 5222:5222 -p 5285:5285 ghcr.io/processone/ejabberd:24.02 live

In another terminal, I had to edit the file .ejabberd-modules/sources/ejabberd-contrib/mod_rest/conf/mod_rest.yml because it has the option allowed_ips with an IP address that my container didn't use.

podman exec -it --user root ejabberd vi .ejabberd-modules/sources/ejabberd-contrib/mod_rest/conf/mod_rest.yml

Then install the module and register a destination user:

$ podman exec -it ejabberd ejabberdctl module_install mod_rest
Module mod_rest has been installed and started.
It's configured in the file:
  /opt/ejabberd/.ejabberd-modules/mod_rest/conf/mod_rest.yml
Configure the module in that file, or remove it
and configure in your main ejabberd.yml

$ podman exec -it ejabberd ejabberdctl register nolan localhost asd
User nolan@localhost successfully registered

Finally, check the offline messages of that user, send a stanza and check it was received:

$ podman exec -it ejabberd ejabberdctl get_offline_count nolan localhost
0

$ wget http://localhost:5285/rest/ --server-response --post-data '<message to="nolan@localhost" from="localhost/rest"><body>World</body></message>'
--2024-04-29 13:38:15--  http://localhost:5285/rest/
Resolving localhost (localhost)... ::1, 127.0.0.1
Connecting to localhost (localhost)|::1|:5285... connected.
HTTP request sent, awaiting response...
  HTTP/1.1 200 OK
  Content-Type: text/html; charset=utf-8
  Content-Length: 2
Length: 2 [text/html]
Saving to: 'index.html'

index.html                  100%[=========================================>]       2  --.-KB/s    in 0s      

2024-04-29 13:38:15 (369 KB/s) - 'index.html' saved [2/2]

$ cat index.html
Ok

$ podman exec -it ejabberd ejabberdctl get_offline_count nolan localhost
1

@AlanChatflix
Copy link
Author

I'm using Ubuntu with NGINX.
I just followed the directions from git:

sudo ejabberdctl module_install mod_rest

And it says it was installed correctly.
When I execute the command to list all the mods installed, it shows mod_rest.

But when I added to ejabberd.yml:

modules:
   mod_rest: {}

It fails if I try to reload ejabberd. If I remove it it works, if I add any mod_rest it fails.
If it's correctly installed with "sudo ejabberdctl module_install mod_red" and I successfully reloaded ejabberd, shouldn't that be enough? Do I need to execute any other command after "sudo ejabberdctl module_install mod_red" ?

@AlanChatflix

This comment was marked as duplicate.

@badlop
Copy link
Member

badlop commented Apr 29, 2024

But when I added to ejabberd.yml:

When running module_install, it also copies the default module configuration, and gets enabled by default. Didn't you get an explanation similar to this?

$ podman exec -it ejabberd ejabberdctl module_install mod_rest
Module mod_rest has been installed and started.
It's configured in the file:
  /opt/ejabberd/.ejabberd-modules/mod_rest/conf/mod_rest.yml
Configure the module in that file, or remove it
and configure in your main ejabberd.yml

If it's correctly installed with "sudo ejabberdctl module_install mod_red"

Please notice that "module_install" performs many tasks:

  • compile the module source code
  • copy the module binary
  • copy the module default configuration
  • enable the module

So you just need to execute "module_install", as I demonstrated in my example setup guide.

@AlanChatflix
Copy link
Author

I didn't use "podman exec -it " .
It's Ubuntu. I just did "sudo ejabberdctl module_install mod_red" and that was enough to return that it was installed and active. That's all.
Shouldn't that be enough for me to just edit ejabberd.yml with mod_rest: {} then reload ejabberd service?

@badlop
Copy link
Member

badlop commented Apr 29, 2024

"sudo ejabberdctl module_install mod_red" and that was enough to return that it was installed and active. That's all.

Thisenables the module, as I said and I demonstrated previously. NO NEED TO EDIT ejabberd.yml, it's already enabled.

me to just edit ejabberd.yml with mod_rest: {} then reload ejabberd service?

I'll repeat again: the module is already enabled. It is mentioned in the command response, did you read it? No need to enable it again in ejabberd.yml, and no need to reload ejabberd service.

@AlanChatflix
Copy link
Author

YES I got it but i WANT TO CONFIG my ejabberd.yml with custom stuff like this:

mod_rest:
    allowed_ips:
      - "127.0.0.1"

and:

-
    port: MY_PORT_BUMBER
    module: ejabberd_http
    request_handlers:
           /rest: mod_rest

etc..
So it should be working LIKE IT DID WITH PREVIOUS EJABBERD, correct?
I had it before. The latest version of eJabberd isn't working with this.

@AlanChatflix
Copy link
Author

@badlop ?

@badlop
Copy link
Member

badlop commented Apr 29, 2024

Aha: If you want to configure some options in your main ejabberd.yml file, you can:

  1. remove the module configuration that is in .ejabberd-modules/mod_rest/conf/mod_rest.yml (either remove the content, or remove the file completely)

  2. Then you can add it as usual in your main ejabberd.yml

@AlanChatflix
Copy link
Author

Thanks. Your tips really helped.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants