1

I have setup the mongooseim [3.3.0] ubuntu 14.04 & it works perfect with android client setup. Then I need to test the REST API for creating room , Then I have got this error when running the swagger documentation.

curl -X GET --header 'Accept: application/json' --header 'Authorization: Basic dXNlcjpwYXNzd29yZA==' 'http://localhost:8089/api/rooms'

curl: (52) Empty reply from server

This is the mongooseim configs which related to REST API.

{ 8089 , 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, [
          {"_", "/api/sse", lasse_handler, [mongoose_client_api_sse]},
          {"_", "/api/messages/[:with]", mongoose_client_api_messages, []},
          {"_", "/api/contacts/[:jid]", mongoose_client_api_contacts, []},
          {"_", "/api/rooms/[:id]",    mongoose_client_api_rooms, []},
          {"_", "/api/rooms/[:id]/config",    mongoose_client_api_rooms_config, []},
          {"_", "/api/rooms/:id/users/[:user]",    mongoose_client_api_rooms_users, []},
          {"_", "/api/rooms/[:id]/messages",    mongoose_client_api_rooms_messages, []}
      ]}
  ]}

This is the swagger document I have referred. https://mongooseim.readthedocs.io/en/3.3.0/swagger/index.html

Sajith Vijesekara
  • 1,324
  • 2
  • 17
  • 52

1 Answers1

3

I noticed the following things:

  1. The curl example you provided tries to send the request to MongooseIM over HTTP
  2. Based on the part of the config file you provided I can see that MongooseIM expects HTTPS traffic.

It looks like changing the endpoint in your curl command to https://localhost:8089/api/rooms will help. Of course, if you run the command on the same machine as MongooseIM is running. Otherwise, please change the localhost to a proper name or IP address of the machine.

What's more, in the config file I can see that the REST API is configured with the default, fake and self-signed certificates. I strongly encourage you to change it to real certificates. For the sake of testing, you will need to add the option -k to your curl command in order to skip cert verification.

michalwski
  • 359
  • 1
  • 3
  • Thanks for help @michalwski . Can't I test with self sign certificates with local setup – Sajith Vijesekara Jun 01 '20 at 10:18
  • curl -X GET --header 'Accept: application/json' --header 'Authorization: Basic dXNlckBsb2NhbGhvc3Q6cGFzc3dvcmQ=' 'https://localhost:8089/api/rooms' -k I put this way still now response This time no response. – Sajith Vijesekara Jun 01 '20 at 10:19
  • 1
    How about this: `curl -k -v -X GET --header 'Accept: application/json' --header 'Authorization: Basic dXNlckBsb2NhbGhvc3Q6cGFzc3dvcmQ=' 'https://localhost:8089/api/rooms'` – michalwski Jun 01 '20 at 12:08
  • When I put this it gives 500 server error. HTTP/1.1 500 Internal Server Error – Sajith Vijesekara Jun 01 '20 at 13:48
  • I have found the issue , mongooseim 3.3.0 not suport create group or get groups API. Thanks for Help – Sajith Vijesekara Jun 01 '20 at 14:13
  • I tries the your request. It gives 500 error And this is the mongooseim server logs. mod_muc_light_db_backend:get_user_rooms Cowboy stream 1 with ranch listener 'ejabberd_cowboy_0.0.0.0_8089' and connection process <0.1399.0> had its request process exit with reason: call to undefined function mod_muc_light_db_backend:get_user_rooms({<<"sajith">>,<<"localhost">>}, undefined) – Sajith Vijesekara Jun 01 '20 at 15:37