ejabberd 1 - cras mqtt

@ejabberd_config:load/1:82 Loading configuration from /etc/ejabberd/ejabberd.yml
2024-04-30 01:35:56.529935+02:00 [info] <0.122.0>@ejabberd_config:load/1:89 Configuration loaded successfully
2024-04-30 01:35:56.635013+02:00 [info] <0.376.0>@ejabberd_systemd:init/1:94 Got no NOTIFY_SOCKET, notifications disabled
2024-04-30 01:35:56.697436+02:00 [info] <0.434.0>@ejabberd_sql_schema:create_table/2:632 Creating table route:
CREATE TABLE route (
    domain text NOT NULL,
    server_host text NOT NULL,
    node text NOT NULL,
    pid text NOT NULL,
    local_hint text NOT NULL
) ENGINE=InnoDB CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE UNIQUE INDEX i_route_domain_server_host_node_pid USING BTREE ON route(domain(191), server_host(191), node(191), pid(191));


2024-04-30 01:35:56.798122+02:00 [info] <0.430.0>@ejabberd_sql_schema:create_table/2:632 Creating table sm:
CREATE TABLE sm (
    usec bigint NOT NULL,
    pid text NOT NULL,
    node text NOT NULL,
    username text NOT NULL,
    server_host text NOT NULL,
    resource text NOT NULL,
    priority text NOT NULL,
    info text NOT NULL
) ENGINE=InnoDB CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE UNIQUE INDEX i_sm_usec_pid USING BTREE ON sm(usec, pid(191));
CREATE INDEX i_sm_node USING BTREE ON sm(node(191));
CREATE INDEX i_sm_server_host_username USING BTREE ON sm(server_host(191), username(191));


2024-04-30 01:35:56.976147+02:00 [info] <0.375.0>@gen_mod:start_modules/0:141 Loading modules for yourdomain.com
2024-04-30 01:35:57.321318+02:00 [info] <0.487.0>@mod_stun_disco:parse_listener/1:599 Won't auto-announce STUN/TURN service on port 3478 (udp) without public IP address, please specify 'turn_ipv4_address' and optionally 'turn_ipv6_address'
2024-04-30 01:35:57.431040+02:00 [info] <0.430.0>@ejabberd_sql_schema:create_table/2:632 Creating table bosh:
CREATE TABLE bosh (
    sid text NOT NULL,
    node text NOT NULL,
    pid text NOT NULL
) ENGINE=InnoDB CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE UNIQUE INDEX i_bosh_sid USING BTREE ON bosh(sid(191));


2024-04-30 01:35:57.526975+02:00 [error] <0.540.0>@mod_mqtt_sql:init/0:36 Backend 'sql' is only supported for db_type
2024-04-30 01:35:57.527228+02:00 [critical] <0.375.0>@gen_mod:start_module/4:184 Failed to start module mod_mqtt: 
{error,{db_failure,{child,undefined,'mod_mqtt_yourdomain.com',
                          {gen_server,start_link,
                                      [{local,'mod_mqtt_yourdomain.com'},
                                       mod_mqtt,
                                       [<<"yourdomain.com">>,
                                        #{access_publish => [],
                                          access_subscribe => [],
                                          cache_life_time => 3600000,
                                          cache_missed => true,
                                          cache_size => 1000,db_type => sql,
                                          match_retained_limit => 1000,
                                          max_queue => 5000,
                                          max_topic_aliases => 100,
                                          max_topic_depth => 8,
                                          queue_type => ram,
                                          ram_db_type => sql,
                                          session_expiry => 300000,
                                          use_cache => true}],
                                       []]},
                          transient,false,60000,worker,
                          [mod_mqtt]}}}
2024-04-30 01:35:57.527400+02:00 [critical] <0.375.0>@gen_mod:maybe_halt_ejabberd/0:283 ejabberd initialization was aborted because a module start failed.
2024-04-30 01:35:57.527416+02:00 [error] <0.540.0>@proc_lib:crash_report/4:539 CRASH REPORT:
  crasher:
    initial call: mod_mqtt:init/1
    pid: <0.540.0>
    registered_name: []
    exception exit: db_failure
      in function  gen_server:init_it/6 (gen_server.erl, line 835)
    ancestors: [ejabberd_gen_mod_sup,ejabberd_sup,<0.122.0>]
    message_queue_len: 0
    messages: []
    links: [<0.465.0>]
    dictionary: []
    trap_exit: false
    status: running
    heap_size: 987
    stack_size: 28
    reductions: 3119
  neighbours:
ejabberd.yml:

cat /etc/ejabberd/ejabberd.yml
###
###              ejabberd configuration file
###
### The parameters used in this configuration file are explained at
###
###       https://docs.ejabberd.im/admin/configuration
###
### The configuration file is written in YAML.
### *******************************************************
### *******           !!! WARNING !!!               *******
### *******     YAML IS INDENTATION SENSITIVE       *******
### ******* MAKE SURE YOU INDENT SECTIONS CORRECTLY *******
### *******************************************************
### Refer to http://en.wikipedia.org/wiki/YAML for the brief description.
###

##
## loglevel: Verbosity of log files generated by ejabberd.
## 0: No ejabberd log at all (not recommended)
## 1: Critical
## 2: Error
## 3: Warning
## 4: Info
## 5: Debug
##
loglevel: 4

# rotation: Disable ejabberd's internal log rotation, as the Debian package
# uses logrotate(8).
log_rotate_size: 10485760
log_rotate_count: 1

# hosts: Domains served by ejabberd.
# You can define one or several, for example:
# hosts:
#   - "example.net"
#   - "example.com"
#   - "example.org"

hosts:
  - yourdomain.com

certfiles:
  - "/etc/ejabberd/cert/cert.pem"
  - "/etc/ejabberd/cert/fullchain.pem"
  - "/etc/ejabberd/cert/privkey.pem"

# TLS configuration
define_macro:
  'TLS_CIPHERS': "HIGH:!aNULL:!eNULL:!3DES:@STRENGTH"
  'TLS_OPTIONS':
    - "no_sslv3"
    - "no_tlsv1"
    - "no_tlsv1_1"
    - "cipher_server_preference"
    - "no_compression"
  'DH_FILE': "/etc/ejabberd/dh2048.pem" # generated with: openssl dhparam -out dhparams.pem 2048
    # generated with: openssl dhparam -out dhparams.pem 2048

c2s_ciphers: 'TLS_CIPHERS'
s2s_ciphers: 'TLS_CIPHERS'
s2s_cafile: "/etc/ssl/certs/ca-certificates.crt"
c2s_protocol_options: 'TLS_OPTIONS'
s2s_protocol_options: 'TLS_OPTIONS'
# c2s_dhfile: 'DH_FILE'
s2s_dhfile: '/etc/ejabberd/dh2048.pem'



listen:
  -
    port: 1883
    ip: "::"
    module: mod_mqtt
    backlog: 1000
    tls: true
  -
    port: 3478
    ip: "::"
    transport: udp
    module: ejabberd_stun
    use_turn: true
    ## The server's public IPv4 address:
    # turn_ipv4_address: "203.0.113.3"
    ## The server's public IPv6 address:
    # turn_ipv6_address: "2001:db8::3"
  -
    port: 5222
    ip: "::"
    module: ejabberd_c2s
    max_stanza_size: 262144
    shaper: c2s_shaper
    access: c2s
    starttls_required: true
    protocol_options: 'TLS_OPTIONS'
  -
    port: 5223
    ip: "::"
    module: ejabberd_c2s
    max_stanza_size: 262144
    shaper: c2s_shaper
    access: c2s
    tls: true
    protocol_options: 'TLS_OPTIONS'

  -
    port: 5269
    ip: "::"
    module: ejabberd_s2s_in
    max_stanza_size: 524288
    shaper: s2s_shaper


  -
    port: 5281
    ip: "::"
    module: ejabberd_http
    tls: true
    protocol_options: 'TLS_OPTIONS'
    request_handlers:
      /ws: ejabberd_http_ws
      /bosh: mod_bosh
      /admin: ejabberd_web_admin
      /.well-known/acme-challenge: ejabberd_acme
      /register: mod_register_web
      /api: mod_http_api
      /mqtt: mod_mqtt
  -
    port: 5443
    ip: "::"
    module: ejabberd_http
    tls: true
    protocol_options: 'TLS_OPTIONS'
    request_handlers:
      /api: mod_http_api
      /bosh: mod_bosh
      ## /captcha: ejabberd_captcha
      ## /upload: mod_http_upload
      /ws: ejabberd_http_ws
  -
    port: 5444
    transport: tcp
    ip: "::"
    module: ejabberd_http
    request_handlers:
     "": mod_http_upload
    tls: true
  -
    port: 5444
    transport: udp
    ip: "::"
    module: ejabberd_http
    request_handlers:
     "": mod_http_upload
    tls: true


## Disabling digest-md5 SASL authentication. digest-md5 requires plain-text
## password storage (see auth_password_format option).
disable_sasl_mechanisms:
  - "digest-md5"
  - "X-OAUTH2"

s2s_use_starttls: required

## Store the plain passwords or hashed for SCRAM:
auth_password_format: scram

auth_scram_hash: sha512

## Full path to a script that generates the image.
## captcha_cmd: "/usr/share/ejabberd/captcha.sh"

auth_method:
       - sql

sql_type: mysql
sql_server: "localhost"
sql_database: "database"
sql_username: "database"
sql_password: "pedro"

new_sql_schema: true

default_db: sql
default_ram_db: sql
sm_db_type: sql

update_sql_schema: true

acl:
  admin:
    user:
      - "ivan@yourdomain.com"

  local:
    user_regexp: ""
  loopback:
    ip:
      - 127.0.0.0/8
      - ::1/128

access_rules:
  local:
    allow: local
  muc_log:
    allow: admin
  muc_admin:
    allow: admin
  roster:
    allow: admin

  c2s:
    deny: blocked
    allow: all
  announce:
    allow: admin
  configure:
    allow: admin
  muc_create:
    allow: local
  pubsub_createnode:
    allow: local
  trusted_network:
    allow: loopback

api_permissions:
  "console commands":
    from:
      - ejabberd_ctl
    who: all
    what: "*"
  "admin access":
    who:
      access:
        allow:
          - acl: loopback
          - acl: admin
      oauth:
        scope: "ejabberd:admin"
        access:
          allow:
            - acl: loopback
            - acl: admin
    what:
      - "*"
      - "!stop"
      - "!start"
  "public commands":
    who:
      ip: 127.0.0.1/8
    what:
      - status
      - connected_users_number

shaper:
  normal:
    rate: 3000
    burst_size: 20000
  fast: 200000

language: "en"

shaper_rules:
  max_user_sessions: 1
  max_user_offline_messages:
    5000: admin
    100: all
  c2s_shaper:
    none: admin
    normal: all
  s2s_shaper: fast

modules:
  mod_adhoc: {}
  mod_admin_extra: {}
  mod_announce:
    access: announce
  mod_block_strangers: {}

  mod_avatar: {}
  mod_blocking: {}
  mod_bosh: {}
  mod_caps: {}
  mod_carboncopy: {}
  mod_client_state: {}
  mod_configure: {}
  ## mod_delegation: {}   # for xep0356
  mod_disco: {}
  mod_fail2ban: {}
  mod_http_api: {}
  mod_http_upload:
    docroot: "/var/www/upload/"
    put_url: https://@HOST@/upload/
  ##   custom_headers:
  ##     "Access-Control-Allow-Origin": "https://@HOST@"
  ##     "Access-Control-Allow-Methods": "GET,HEAD,PUT,OPTIONS"
  ##     "Access-Control-Allow-Headers": "Content-Type"
  mod_last: {}
  mod_mam:
  ##   ## Mnesia is limited to 2GB, better to use an SQL backend
  ##   ## For small servers SQLite is a good fit and is very easy
  ##   ## to configure. Uncomment this when you have SQL configured:
    db_type: sql
    assume_mam_usage: true
    default: always

  mod_mqtt:
    db_type: mnesia
    ram_db_type: mnesia
  mod_muc:
    host: "conference.@HOST@"
    access:
      - allow
    access_admin:
      - allow: admin
    access_create: muc_create
    access_persistent: muc_create
    access_mam:
      - allow
    default_room_options:
      allow_user_invites: true
      allow_visitor_status: true
      persistent: true
      mam: true
      members_by_default: false
      allow_subscription: true
      anonymous: false
  mod_muc_admin: {}
  mod_offline:
    access_max_user_messages: max_user_offline_messages
  mod_ping:
   send_pings: true
   ping_interval: 3
  mod_pres_counter:
    count: 5
    interval: 60
  mod_privacy: {}
  mod_private: {}
  mod_proxy65:
   access: local
   host: "proxy.@HOST@"
   name: "yourdomain.com bytestream"
   ip: "192.168.1.55"
   port: 6yy6
   max_connections: 5
   auth_type: plain
  mod_pubsub:
    access_createnode: pubsub_createnode
    plugins:
      - flat
      - pep
    force_node_config:
      "eu.siacs.conversations.axolotl.*":
        access_model: open
      ## Avoid buggy clients to make their bookmarks public
      storage:bookmarks:
        access_model: whitelist
  mod_push: {}
  mod_push_keepalive: {}
  mod_register:
    captcha_protected: true
    welcome_message:
      subject: "Welcome!"
      body: |-
        Hi.
         Welcome to this XMPP server.
    redirect_url: "https://yourdomain.com"
    registration_watchers:
     - "ivan@yourdomain.com"
    ip_access: trusted_network
  ##   ## Only accept registration requests from the "trusted"
  ##   ## network (see access_rules section above).
  ##   ## Think twice before enabling registration from any
  ##   ## address. See the Jabber SPAM Manifesto for details:
  ##   ## https://github.com/ge0rg/jabber-spam-fighting-manifesto
  ##   ip_access: trusted_network
  mod_register_web: {}
  mod_roster:
    versioning: true
  mod_s2s_dialback: {}
  mod_shared_roster: {}
  mod_sic: {}
  mod_stream_mgmt:
    resend_on_timeout: if_offline
  mod_stun_disco:
    access: local
    offer_local_services: true
    secret: rf
    services:
  ##    -
  ##     host: yourdomain.com
  ##     port: 3444
  ##     type: stun
  ##     transport: udp
  ##     restricted: false

  ##    -
  ##     host: yourdomain.com
  ##     port: 3444
  ##     type: turn
  ##     transport: udp
  ##     restricted: true

      -
        host: yourdomain.com
        port: 3444
        type: stuns
        transport: udp
  ##      transport: tcp
        restricted: false

      -
        host: yourdomain.com
        port: 3444
        type: turns
        transport: udp
  ##      transport: tcp
        restricted: true

      -
        host: yourdomain.com
        port: 3444
        type: stuns
        transport: tcp
        restricted: false

      -
        host: yourdomain.com
        port: 8443
        type: turns
        transport: tcp
        restricted: true

  mod_muc_log:
    access_log: muc_log
    dirtype: subdirs
    file_permissions:
      mode: 644
      group: 33
    timezone: local
    top_link:
      "http://www.yourdomain.com/": "yourdomain.com chastni comunicaci"

  mod_vcard:
    search: true
  mod_vcard_xupdate: {}
  mod_version:
    show_os: false

### Local Variables:
### mode: yaml
### End:
### vim: set filetype=yaml tabstop=8