Git Product home page Git Product logo

mongooseim-docker's Introduction

mongooseim-docker

MongooseIM is Erlang Solutions' robust and efficient XMPP server aimed at large installations. Specifically designed for enterprise purposes, it is fault-tolerant, can utilize resources of multiple clustered machines and easily scale in need of more capacity (by just adding a box/VM). Its home at GitHub is http://github.com/esl/MongooseIM.

Quick start guide

The docker images for MongooseIM are available at hub.docker.com. You only need this repo if you want to build a custom image.

The ./build.sh script is a good starting point, because it automatically performs the whole build procedure. Individual build steps are described below.

Building a MongooseIM tarball

In order to build the MongooseIM tarball, a builder image and container need to be created. You can create an image by running the following command:

docker build -f Dockerfile.builder -t mongooseim-builder .

After that you can run the builder container. It's important to mount the container's /builds directory as a volume, because the MongooseIM tarball will be placed there after the build. For simplicity it's assumed that the environment variable VOLUMES is exported and set to an existing absolute path, e.g. pwd.

docker run --rm --name mongooseim-builder -h mongooseim-builder -e TARBALL_NAME=mongooseim \
       -v ${VOLUMES}/builds:/builds mongooseim-builder

${VOLUMES}/builds will contain a build.log file with logs and, if the build is successful, the resulting tarball: mongooseim-${ARCH}.tar.gz, where ${ARCH} is the target architecture.

Modifying Erlang/OTP version

You can modify which Erlang/OTP version is used by MongooseIM when creating a builder image by overriding the OTP_VSN argument defined in Dockerfile.builder.

docker build --build-arg OTP_VSN=26.1.2 -f Dockerfile.builder -t mongooseim-builder .

Building a custom version

Should you need to build a custom version of MongooseIM, you can run the builder container in the interactive mode:

docker run -it --rm --name mongooseim-builder -h mongooseim-builder -e TARBALL_NAME=mongooseim \
       -v ${VOLUMES}/builds:/builds mongooseim-builder bash

Now you can execute /build.sh with additional arguments. This command will by default build MongooseIM's master branch from: https://github.com/esl/MongooseIM. This can be changed by specifying a parameter to the build.sh command:

/build.sh project_name repo commit
  • project_name - friendly name for the build

  • commit - commit or branch or tag - what to checkout?

  • repo - where to checkout from

In order to build a specific commit, following command can be used:

/build.sh MongooseIM https://github.com/esl/MongooseIM a37c196

When building a private project, set up your git credentials before running the build command.

Creating MongooseIM containers

In order to build the image, the MongooseIM tarball has to be copied to the member directory:

cp builds/mongooseim-${ARCH}.tar.gz ./member/

The image can now be build from Dockerfile.member:

docker build -f Dockerfile.member -t mongooseim .

Running MongooseIM

The member container can be created and started with the following command:

docker run -dtP -h mongooseim-1 --name mongooseim-1 mongooseim

You can check that docker logs mongooseim-1 shows something similar to:

...
MongooseIM cluster primary node mongooseim@mongooseim-1
Clustered mongooseim@mongooseim-1 with mongooseim@mongooseim-1
Root: /usr/lib/mongooseim
Exec: /usr/lib/mongooseim/erts-13.1.5/bin/erlexec -boot /usr/lib/mongooseim/releases/6.1.0/start -embedded -config /usr/lib/mongooseim/etc/app.config -args_file /usr/lib/mongooseim/etc/vm.args -args_file /usr/lib/mongooseim/etc/vm.dist.args -- live --noshell -noinput +Bd
when=2023-10-24T14:28:03.386139+00:00 level=warning what=report_transparency pid=<0.574.0> at=service_mongoose_system_metrics:report_transparency/1:175 text="We are gathering the MongooseIM system's metrics to analyse the trends and needs of our users, improve MongooseIM, and know where to focus our efforts. For more info on how to customise, read, enable, and disable these metrics visit: \
- MongooseIM docs - \
      https://esl.github.io/MongooseDocs/latest/operation-and-maintenance/System-Metrics-Privacy-Policy/ \
- MongooseIM GitHub page - https://github.com/esl/MongooseIM \
The last sent report is also written to a file log/system_metrics_report.json" report_filename=log/system_metrics_report.json

We can health-check the MongooseIM node with telnet. To do that, you need to provide the IP of the container (usually 127.0.0.1) and the published TCP port which translates to container’s port 5222. In order to find the port you can use the following docker command:

$ docker ps -f "name=mongooseim-1" --format "{{.Names}}: {{.Ports}}"
mongooseim-1: 0.0.0.0:32772->4369/tcp, 0.0.0.0:32771->5222/tcp, 0.0.0.0:32770->5269/tcp, 0.0.0.0:32769->5280/tcp, 0.0.0.0:32768->9100/tcp

In the example above you can see that port 5222 inside the container was published on port 32771 on the docker host machine. It can be used to check if the server is really listening on that port:

$ telnet 127.0.0.1 32771
Connected to localhost.
Escape character is '^]'.

Success! MongooseIM is accepting XMPP connections.

Customising the configuration

You can override the default configuration files by providing them using docker volumes. Let's assume on the local machine there is directory mongooseim-1 with the following content:

$ tree mongooseim-1
mongooseim-1
└── mongooseim.toml
└── app.config
└── vm.args

Now we can run the container:

docker run -dt -h mongooseim-1 --name mongooseim-1 -p 5222:5222 -v `pwd`/mongooseim-1:/member mongooseim

The server will use the customised configuration files. There is also a vm.dist.args file which can be overwritten in the same way.

Setting up a cluster

There are two methods of clustering: the default, automatic one and a method where you have more control over the cluster formation.

Default clustering

To use default clustering behaviour, your containers need both container names (--name option) and host names (-h option) with the -n suffix, where n are consecutive integers starting with 1 (configurable with MASTER_ORDINAL env variable), e.g. mongooseim-1, mongooseim-2 and so on. Make sure you have started a node with -${MASTER_ORDINAL} suffix first (e.g. -h mongooseim-1 and --name mongooseim-1), as all the other nodes will connect to it when joining the cluster.

Few things are important here:

  1. The following parameters must be set to the same value if used in docker/docker-compose. The second and all the subsequent containers have the same requirement.

    • -h option sets HOSTNAME environment variable for the container which in turn sets long hostname of the machine. The start.sh script uses it to generate the Erlang node name if NODE_TYPE=name. If NODE_TYPE=sname (default), short hostname will be used instead. If the value provided to -h option is already a short hostname, it will be used as is, otherwise it will be shortened (longest part that doesn't contain '.' character). If you need to make the host part of the node name different from HOSTNAME (or use an IP address instead), you can do it with the NODE_HOST environment variable, e.g. -e NODE_HOST=192.168.1.1.
    • --name is required to provide automatic DNS resolution between the containers. See Docker network documentation page for more details.
  2. Format of the host name:

    • Host name of the first container must be in the ${NODE_NAME}-${MASTER_ORDINAL} format. That allows start.sh to identify the primary node of the cluster.
    • All the subsequent containers must follow the ${NODE_NAME}-N host name format, where N > ${MASTER_ORDINAL}.

Example

Create a user-defined bridge network and start two nodes connected to it:

docker network create mim
docker run -dt --net mim -h mongooseim-1 --name mongooseim-1 mongooseim
docker run -dt --net mim -h mongooseim-2 --name mongooseim-2 mongooseim

The nodes should already form a cluster. Let's check it:

$ docker exec mongooseim-1 /usr/lib/mongooseim/bin/mongooseimctl mnesia systemInfo --keys '["running_db_nodes"]'
{
  "data" : {
    "mnesia" : {
      "systemInfo" : [
        {
          "result" : [
            "mongooseim@mongooseim-2",
            "mongooseim@mongooseim-1"
          ],
          "key" : "running_db_nodes"
        }
      ]
    }
  }
}
$ docker exec mongooseim-2 /usr/lib/mongooseim/bin/mongooseimctl mnesia systemInfo --keys '["running_db_nodes"]'
{
  "data" : {
    "mnesia" : {
      "systemInfo" : [
        {
          "result" : [
            "mongooseim@mongooseim-1",
            "mongooseim@mongooseim-2"
          ],
          "key" : "running_db_nodes"
        }
      ]
    }
  }
}

Kubernetes notes

Default clustering may work as part of Kubernetes StatefulSet deployment with only two changes:

Manual clustering

With the manual clustering method, you need to explicitly specify the name of the node to join the cluster with via the CLUSTER_WITH environment variable. You may also disable clustering during container startup altogether by setting JOIN_CLUSTER=false variable (it's set to true by default).

Examples

Let's try providing a name of the node to join the cluster with manually:

docker run -dt --net mim -h first-node --name first-node -e JOIN_CLUSTER=false mongooseim
docker run -dt --net mim -h second-node --name second-node -e CLUSTER_WITH=mongooseim@first-node mongooseim

The first command starts a node and tells it not to try to join any clusters (as there are no other nodes). We then tell the second node to join the cluster with the first node.

You can now check that the nodes have formed the cluster:

$ docker exec first-node /usr/lib/mongooseim/bin/mongooseimctl mnesia systemInfo --keys '["running_db_nodes"]'
{
  "data" : {
    "mnesia" : {
      "systemInfo" : [
        {
          "result" : [
            "mongooseim@second-node",
            "mongooseim@first-node"
          ],
          "key" : "running_db_nodes"
        }
      ]
    }
  }
}
$ docker exec second-node /usr/lib/mongooseim/bin/mongooseimctl mnesia systemInfo --keys '["running_db_nodes"]'
{
  "data" : {
    "mnesia" : {
      "systemInfo" : [
        {
          "result" : [
            "mongooseim@first-node",
            "mongooseim@second-node"
          ],
          "key" : "running_db_nodes"
        }
      ]
    }
  }
}

Database setup

MongooseIM can be integrated with various databases and other external services. For example, let's run a PostgreSQL container:

docker run -d --name mongooseim-postgres --net mim \
       -e POSTGRES_PASSWORD=mongooseim -e POSTGRES_USER=mongooseim \
       -v ${PATH_TO_MONGOOSEIM_PGSQL_FILE}:/docker-entrypoint-initdb.d/pgsql.sql:ro \
       -p 5432:5432 postgres

${PATH_TO_MONGOOSEIM_PGSQL_FILE} is an absolute path to priv/pgsql.sql, which can be found in the MongooseIM repo.

Don't forget to configure the outgoing connection pools in mongooseim.toml to connect with the services you set up!

Using CETS

You can use CETS instead of Mnesia - see the tutorial for more details. You will need to start all nodes with JOIN_CLUSTER=false.

docker run -dt --net mim -h mongooseim-1 --name mongooseim-1 -v `pwd`/mongooseim-1:/member -e JOIN_CLUSTER=false mongooseim
docker run -dt --net mim -h mongooseim-2 --name mongooseim-2 -v `pwd`/mongooseim-2:/member -e JOIN_CLUSTER=false mongooseim

You can check the CETS status on both nodes to see if the clustering is successful:

$ docker exec mongooseim-1 /usr/lib/mongooseim/bin/mongooseimctl cets systemInfo
{
  "data" : {
    "cets" : {
      "systemInfo" : {
        (...)
        "availableNodes" : [
          "mongooseim@mongooseim-1",
          "mongooseim@mongooseim-2"
        ]
      }
    }
  }
}

$ docker exec mongooseim-2 /usr/lib/mongooseim/bin/mongooseimctl cets systemInfo
{
  "data" : {
    "cets" : {
      "systemInfo" : {
        (...)
        "availableNodes" : [
          "mongooseim@mongooseim-2",
          "mongooseim@mongooseim-1"
        ]
      }
    }
  }
}

This work, though it's not reflected in git history, was bootstrapped from https://github.com/ppikula/MongooseIM-docker/.

mongooseim-docker's People

Contributors

arcusfelis avatar arkgil avatar chrzaszcz avatar denysgonchar avatar erszcz avatar ivanov-aleksander avatar januszjakubiec avatar kzemek avatar lucafavatella avatar michalwski avatar mkacper avatar nelsonvides avatar rslota avatar vivekkiran avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mongooseim-docker's Issues

Successfully installed from Docker, Now what?

I now able to manage successully installed mongooseim from Docker.

===> Starting relx build process ...
===> Resolving OTP Applications from directories:
          /tmp/mongooseim/_build/prod/lib
          /usr/lib/erlang/lib
===> Resolved mongooseim-2.1.1
===> Including Erts from /usr/lib/erlang
===> release successfully created!
[2018-02-06 12:13:28] /builds/mongooseim-MongooseIM-master-2018-02-06_121317.tar.gz is ready

But, it's neither accessible to browser with floatingip:5222 or neither any commands are working. Kindly help, commands are like these:

root@mongooseim:/# mongooseimctl status
mongooseimctl: command not found
root@mongooseim:/# mongooseimctl start
mongooseimctl: command not found

and Docker PS commands gives:

root@mongooseim:/var/lib/docker/volumes# docker ps
CONTAINER ID        IMAGE                           COMMAND             CREATED             STATUS              PORTS               NAMES
bb97e90e96fb        mongooseim/mongooseim-builder   "/sbin/my_init"     3 hours ago         Up 3 hours                              mongooseim-builder

and When I try to start docker: I just stuck something like this:

root@mongooseim:/var/lib/docker# docker run -it mongooseim/mongooseim-builder
*** Running /etc/my_init.d/00_regen_ssh_host_keys.sh...
*** Running /etc/rc.local...
*** Booting runit daemon...
*** Runit started as PID 8

Checking cluster membership is not correct

I have faced and issue with a cluster with more than 10 nodes. I have created PR 30 to fix this issue.
But I found the second issue:
The condition that checks if node already joined the cluster is not correct.
For example:

  1. Node mongooseim-10 fails to join to cluster because issue PR 30 as result pod will be restarted. But mnesia folder will be created.
  2. Next start of the node mongooseim-10 skip joining the cluster because mnesia folder exist. As a result, it will be standalone node.

Docker image broken given no esl-erlang for Ubuntu Xenial

Get:7 http://packages.erlang-solutions.com/debian xenial/contrib amd64 Packages [49.2 kB]
[...]
E: Version '1:17.5.3' for 'esl-erlang' was not found

As shown, the version specified in the Dockerfile does not exist as deb package for ubuntu xenial. Browsing the erl-solutions website, for 17.5.3 the latest one is trusty. So, there are 2 ways to solve this:

  1. A esl-erlang:1:17.5.3 deb pkg is created and upload it to xenial repos
  2. Rollback phusion/baseimage-docker to a previous version which uses trusty (ie: 0.9.18)

A similar thing happened last time for ppikula's image:
ppikula/mongooseim-docker@87711f4

Issue with second node of mongooseim cluster (docker image)

Hello all

I am trying to deploy cluster with 2 nodes using commands below:

docker network create mim_cluster

docker run -d -t --network mim_cluster -h mongooseim-1 --name mongooseim-1 -v `pwd`/mongooseim-dev-official:/usr/lib/mongooseim/etc -p 5222:5222 -p 5280:5280 -p 9100:9100 mongooseim/mongooseim:latest

docker run -d -t --network mim_cluster -h mongooseim-2 --name mongooseim-2 -v `pwd`/mongooseim-dev-official:/usr/lib/mongooseim/etc mongooseim/mongooseim:latest

It attachment you can see output of:

docker logs mongooseim-1

docker logs mongooseim-2

mongooseim-1.log
mongooseim-2.log

2nd node error messages:

14:15:11.805 [error] Error in process <0.309.0> on node 'mongooseim@mongooseim-2' with exit value:
{badarg,[{ets,insert,[mnesia_gvar,{last_error,{{aborted,{node_not_running,'mongooseim@mongooseim-2'}},[{mnesia_loader,wait_on_load_complete,1,[{file,"mnesia_loader.erl"},{line,359}]},{mnesia_tm,apply_fun,3,[{file,"mnesia_tm.erl"},{line,840}]},{mnesia_tm,execute_transaction,5,[{file,"mnesia_tm.erl"},{line,816}]},{mnesia_loader,init_receiver,5,[{file,"mnesia_loader.erl"},{line,285}]},{mnesia_loader,do_get_network_copy,5,[{file,"mnesia_loader.erl"},{line,221}]},{mnesia_controller,'-load_table_fun/1-fun-4-',5,[{file,"mnesia_controller.erl"},{line,2186}]},{mnesia_controller,'-load_and_reply/2-fun-0-',2,[{file,"mnesia_controller.erl"},{line,2133}]}]}}],[]},{mnesia_lib,set,2,[{file,"mnesia_lib.erl"},{line,443}]},{mnesia_lib,fix_error,1,[{file,"mnesia_lib.erl"},{line,906}]},{mnesia_tm,return_abort,3,[{file,"mnesia_tm.erl"},{line,962}]},{mnesia_loader,init_receiver,5,[{file,"mnesia_loader.erl"},{line,285}]},{mnesia_loader,do_get_network_copy,5,[{file,"mnesia_loader.erl"},{line,221}]},{mnesia_controller,'-load_table_fun/1-fun-4-',5,[{file,"mnesia_controller.erl"},{line,2186}]},{mnesia_controller,'-load_and_reply/2-fun-0-',2,[{file,"mnesia_controller.erl"},{line,2133}]}]}
14:15:11.805 [error] Error in process <0.310.0> on node 'mongooseim@mongooseim-2' with exit value:
{badarg,[{ets,insert,[mnesia_gvar,{last_error,{{aborted,{node_not_running,'mongooseim@mongooseim-2'}},[{mnesia_loader,wait_on_load_complete,1,[{file,"mnesia_loader.erl"},{line,359}]},{mnesia_tm,apply_fun,3,[{file,"mnesia_tm.erl"},{line,840}]},{mnesia_tm,execute_transaction,5,[{file,"mnesia_tm.erl"},{line,816}]},{mnesia_loader,init_receiver,5,[{file,"mnesia_loader.erl"},{line,285}]},{mnesia_loader,do_get_network_copy,5,[{file,"mnesia_loader.erl"},{line,221}]},{mnesia_controller,'-load_table_fun/1-fun-4-',5,[{file,"mnesia_controller.erl"},{line,2186}]},{mnesia_controller,'-load_and_reply/2-fun-0-',2,[{file,"mnesia_controller.erl"},{line,2133}]}]}}],[]},{mnesia_lib,set,2,[{file,"mnesia_lib.erl"},{line,443}]},{mnesia_lib,fix_error,1,[{file,"mnesia_lib.erl"},{line,906}]},{mnesia_tm,return_abort,3,[{file,"mnesia_tm.erl"},{line,962}]},{mnesia_loader,init_receiver,5,[{file,"mnesia_loader.erl"},{line,285}]},{mnesia_loader,do_get_network_copy,5,[{file,"mnesia_loader.erl"},{line,221}]},{mnesia_controller,'-load_table_fun/1-fun-4-',5,[{file,"mnesia_controller.erl"},{line,2186}]},{mnesia_controller,'-load_and_reply/2-fun-0-',2,[{file,"mnesia_controller.erl"},{line,2133}]}]}
14:15:11.826 [info] Application mnesia exited with reason: stopped
14:15:16.055 [info] Checking STUN stun.freeswitch.org
:0: Warning: export_all flag enabled - all functions will be exported
14:15:16.211 [info] NkPACKET v0.6.1 has started.
14:15:16.211 [info] Main IP is 172.19.0.3 (::1). External IP is 28.101.102.87
14:15:16.248 [info] NkSERVICE vv0.2.0 has started.
:0: Warning: export_all flag enabled - all functions will be exported
14:15:16.304 [info] NkSIP v0.5.0 has started

What is wrong?

Is MongooseIM Docker Project Dead?

HI, this looks like a great project how to build and run the mongooseIM as containers, I'm working to build them as a docker-compose which you can simply deploy running docker compose up or building a stack in docker Swarm.

I'm trying to add the database as well, but then I cannot see any reference of the files or details where de back end rest is or what are the steps for mongooseIM init the database.

So basically my question is..

Is this docker documentation a project that could run actually as a cluster and with all the features that MongooseIM offers ?

Builder Fails for Mongooseim 2.0.1 (stable release)

When running:

$ docker exec -i mongooseim-builder /build.sh MongooseIM https://github.com/esl/MongooseIM 2.0.1

==> rel (generate)
ERROR: Unable to generate spec: read file info /usr/lib/erlang/man/man1/gcov-tool.1.gz failed
ERROR: Unexpected error: rebar_abort
ERROR: generate failed while processing /tmp/mongooseim/rel: rebar_abort
Makefile:101: recipe for target 'rel' failed
make: *** [rel] Error 1
build failed

Not able to build the mongooseim when repo is a private repo

Not able to build the mongooseim when the repo is a private repo

docker exec -i mongooseim-builder /build.sh project_name repo commit

I am running our app named 'foo'

docker exec -i mongooseim-builder /build.sh foo https://gitlab.com/backend/foo.git 1567137e7337453d65373e00dacfd79f2d64a457

I get the following error.

Cloning into '/tmp/mongooseim'...
fatal: could not read Username for 'https://gitlab.com/': No such device or address
[2020-08-10 01:21:31] build failed

I tried creating ssh keys inside a docker container and putting the public key in Gitlab and then

I tried using the git protocol URL as

docker exec -i mongooseim-builder /build.sh foo [email protected]:backend/foo.git 1567137e7337453d65373e00dacfd79f2d64a457

It gets stuck at

[2020-08-10 01:26:01] do_build: chat 1567137e7337453d65373e00dacfd79f2d64a457 [email protected]:backend/foo.git
Cloning into '/tmp/mongooseim'

Nothing seems helping.

Remove tar.gz from root

When starting a MongooseIM image using:

docker run -d -t -h mongooseim-1 --name mongooseim-1 -p 5222:5222 mongooseim/mongooseim:latest

I noticed that the release archive was still at the root of the container:

root@mongooseim-1:/# ls -la mongooseim.tar.gz 
-rw-rw-r-- 1 root root 41676824 Apr 11 16:02 mongooseim.tar.gz

It seems like you could get delete it after decompressing it, reducing the size of the container.

Build Failing !!

I'm a newbie and trying to test mongooseim, and a beginner with docker. Earlier, using openfire for my app and now willing to hands-on with mongooseim. There is no manual to install, configure, requisites, minimum server required, dependencies etc. No tutorial on youtube for beginners and I'm frustrated by accessing tabs one by one in the browser.

Played with Docker whole day to learning, and finally got error:

make[1]: Leaving directory '/tmp/mongooseim/_build/default/lib/re2/c_src/re2'
===> Hook for {pc,compile} failed!

Makefile:27: recipe for target 'rel' failed
make: *** [rel] Error 1
[2018-02-06 09:50:00] build failed

I used almost all websites, git wiki, readme, and others blog as well. But helpless to install. Will anyone put the tutorial to install it with a droplet on the Digital Ocean?

Improve README for Clustering Nodes with Docker - Error clustering node

Hi, guys!

Got a clustering node error when following your README. The new member nodes get timeouts. For newer versions of docker it is better to use networks. Got it working running:

# create cluster
docker network create --driver bridge mim
docker run -t -d --net mim -h mongooseim-1 --name mongooseim-1  mongooseim
docker run -t -d --net mim -h mongooseim-2 --name mongooseim-2  mongooseim

# check cluster
docker exec -it mongooseim-1 /usr/lib/mongooseim/bin/mongooseimctl mnesia running_db_nodes
docker exec -it mongooseim-2 /usr/lib/mongooseim/bin/mongooseimctl mnesia running_db_nodes

Kind Regards!

cowboy doesn't answer to requests from external network

I have host with IP 172.17.0.148. There is mongooseim-docker with IP 172.25.0.7 on that host.
Cowboy is listening to port 8088.
Configuration is default except next lines:

  { {8088, "172.25.0.7"} , ejabberd_cowboy, [
      {num_acceptors, 10},
      {transport_options, [{max_connections, 1024}]},
      {modules, [
          {"172.25.0.7", "/api", mongoose_api_admin, []}
      ]}
  ]},

  { {8089, "172.25.0.7"} , ejabberd_cowboy, [
      {num_acceptors, 10},
      {transport_options, [{max_connections, 1024}]},
      {protocol_options, [{compress, true}]},
      {ssl, [{certfile, "priv/ssl/fake_cert.pem"}, {keyfile, "priv/ssl/fake_key.pem"}, {password, ""}]},
      {modules, [
          {"172.25.0.7", "/api/sse", lasse_handler, [mongoose_client_api_sse]},
          {"172.25.0.7", "/api/messages/[:with]", mongoose_client_api_messages, []},
          {"172.25.0.7", "/api/contacts/[:jid]", mongoose_client_api_contacts, []},
          {"172.25.0.7", "/api/rooms/[:id]",    mongoose_client_api_rooms, []},
          {"172.25.0.7", "/api/rooms/[:id]/config",    mongoose_client_api_rooms_config, []},
          {"172.25.0.7", "/api/rooms/:id/users/[:user]",    mongoose_client_api_rooms_users, []},
          {"172.25.0.7", "/api/rooms/[:id]/messages",    mongoose_client_api_rooms_messages, []},
          %% Swagger 
          {"172.25.0.7", "/api-docs", cowboy_swagger_redirect_handler, {priv_file, cowboy_swagger, "swagger/index.html"}},
          {"172.25.0.7", "/api-docs/swagger.json", cowboy_swagger_json_handler, #{}},
          {"172.25.0.7", "/api-docs/[...]", cowboy_static, {priv_dir, cowboy_swagger, "swagger", [{mimetypes, cow_mimetypes, all}]}} 
      ]}
  ]},

I'm running mongooseim-docker with next command:

/usr/bin/docker run -d -t --network mim_cluster -h mongooseim-1 --name mongooseim-1 -v `pwd`/mongooseim-def-off:/member -p 5222:5222 -p 8088:8088 mongooseim/mongooseim

I am getting answer if I run next on host:

/usr/bin/curl -X GET --header 'Accept: application/json' 'http://172.25.0.7:8088/api/users/localhost'

But I can't get any answer when I run command from servers from 172.17.0.0 network. Say, from server with IP 172.17.0.150:

/usr/bin/curl -X GET --header 'Accept: application/json' 'http://172.17.0.148:8088/api/users/localhost'

I have tried to substitute 172.25.0.7 with 0.0.0.0, 127.0.0.1 and 172.17.0.148 in mongooseim.cfg, but it didn't help.

I can 'telnet 172.17.0.148 8088' from 172.17.0.150 and make 'GET'. It gives me the next:

telnet 172.17.0.148 8088
Trying 172.17.0.148...
Connected to 172.17.0.148.
Escape character is '^]'.
GET
HTTP/1.1 400 Bad Request
connection: close
content-length: 0

Connection closed by foreign host.

Execution of 'telnet 172.17.0.148 5222' from 172.17.0.150 gives:

telnet 172.17.0.148 5222
Trying 172.17.0.148...
Connected to 172.17.0.148.
Escape character is '^]'.
GET
<?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' id='FB93302CFE4F9BED' from='localhost' version='1.0'><stream:error><xml-not-well-formed xmlns='urn:ietf:params:xml:ns:xmpp-streams'/></stream:error></stream:stream>Connection closed by foreign host.

Question:

How do I configure mongooseim (cowboy), so I could make requests from servers from 172.17.0.0 network?

Unable to connect non-TLS: `unable to verify the first certificate`

I am running the mongooseim docker image locally, have created a test account, but am unable to connect due to a TLS error. From what I've read mongooseim should be defaulting to non-TLS unless provided with certs (which I have not done). Similarly, xmpp.js will default to non-TLS as well.

I've broken it down to as simple an example as I could. Any help would be greatly appreciated, I feel like I may be overlooking something quite simple.

start service and create user

$ docker run -d -t -h mongooseim-1 --name mongooseim-1 -p 5222:5222 mongooseim/mongooseim:4.2.0
$ docker exec mongooseim-1 /usr/lib/mongooseim/bin/mongooseimctl register_identified jimmy localhost passw0rd

connect

Using xmpp.js node library, here's a simplified script (test-client.js) which illustrates the problem:

const { client } = require("@xmpp/client");

(function () {
  const c = client({
    service: 'xmpp://localhost',
    username: 'jimmy',
    password: 'passw0rd'
  });

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

  c.start().then(() => {
    console.log('connection successful');
  }).catch((err) => {
    console.log(`connect error: ${err}`);
  });
})();
$ node test-client.js
connect error: Error: unable to verify the first certificate
node:internal/process/promises:246
          triggerUncaughtException(err, true /* fromPromise */);
          ^

Error: unable to verify the first certificate
    at TLSSocket.onConnectSecure (node:_tls_wrap:1530:34)
    at TLSSocket.emit (node:events:394:28)
    at TLSSocket._finishInit (node:_tls_wrap:944:8)
    at TLSWrap.ssl.onhandshakedone (node:_tls_wrap:725:12)
Emitted 'error' event on Client instance at:
    at node_modules/@xmpp/middleware/index.js:19:30
    at processTicksAndRejections (node:internal/process/task_queues:96:5) {
  code: 'UNABLE_TO_VERIFY_LEAF_SIGNATURE'
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.