Ejabberd: Can't get PUSH-Notifications to work properly

Created on 5 Feb 2021  路  6Comments  路  Source: processone/ejabberd

Environment

  • ejabberd version: 21.1.0 (latest on the date)
  • Erlang version:Erlang (SMP,ASYNC_THREADS) (BEAM) emulator version 11.1.7
  • OS: Linux (Ubuntu 20.04.1 LTS 64-bit)
  • Installed from: source

Installation order:

./autogen.sh
./configure --enable-user=ejabber --enable-odbc --enable-pgsql --enable-latest-deps
make

sudo make install

Configuration:

hosts:
  - "localhost"
  - "im.local.com"
auth_method: [external]
extauth_program: "/home/ejabber/auth.py"
auth_use_cache: false
extauth_pool_size: 4
default_db: sql
sql_type: pgsql
sql_server: "127.0.0.1"
sql_database: "ejabberd"
sql_username: "ejabberd"
sql_password: "ejabberd"
new_sql_schema: true
loglevel: 4
log_rotate_size: 10485760
log_rotate_count: 1
certfiles:
  - "/home/ejabber/ejabberd.pem"
listen:
  - port: 5222
    ip: "0.0.0.0"
    module: ejabberd_c2s
    max_stanza_size: 262144
    shaper: c2s_shaper
    access: c2s
    starttls_required: true
    starttls: true
  - port: 5223
    ip: "::"
    tls: true
    module: ejabberd_c2s
    max_stanza_size: 262144
    shaper: c2s_shaper
    access: c2s
    starttls_required: true
  - port: 5269
    ip: "::"
    module: ejabberd_s2s_in
    max_stanza_size: 524288
  - port: 5443
    ip: "::"
    module: ejabberd_http
    tls: true
    request_handlers:
      /admin: ejabberd_web_admin
      /api: mod_http_api
      /bosh: mod_bosh
      /captcha: ejabberd_captcha
      /upload: mod_http_upload
      /ws: ejabberd_http_ws
  - port: 5280
    ip: "::"
    module: ejabberd_http
    request_handlers:
      /admin: ejabberd_web_admin
      /.well-known/acme-challenge: ejabberd_acme
  - port: 3478
    ip: "::"
    transport: udp
    module: ejabberd_stun
    use_turn: true
  - port: 1883
    ip: "::"
    module: mod_mqtt
    backlog: 1000
s2s_use_starttls: optional
acl:
  admin:
    user:
      - "6baf5ed1-f5d9-4326-acbc-a8a8ad2e828b": "localhost"
  local:
    user_regexp: ""
  loopback:
    ip:
      - "127.0.0.0/8"
      - "::1/128"
      - "::FFFF:127.0.0.1/128"
access_rules:
  local:
    - allow: local
  c2s:
    - deny: blocked
    - allow
  announce:
    - allow: admin
  configure:
    - allow: admin
  pubsub_createnode:
    - allow: local
  register:
    - allow
  trusted_network:
    - allow: loopback
  s2s:
    - 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: 1000
  fast: 50000
shaper_rules:
  max_user_sessions: 10
  max_user_offline_messages:
    - 5000: admin
    - 100
  c2s_shaper:
    - none: admin
    - normal
  s2s_shaper: fast
modules:
  mod_adhoc: {}
  mod_admin_extra: {}
  mod_announce:
    access: announce
  mod_avatar: {}
  mod_bosh: {}
  mod_caps: {}
  mod_carboncopy: {}
  mod_client_state: {}
  mod_configure: {}
  mod_disco: {}
  mod_fail2ban: {}
  mod_http_api: {}
  mod_last: {}
  mod_mam:
    assume_mam_usage: true
    default: always
  mod_offline:
    access_max_user_messages: max_user_offline_messages
  mod_ping: {}
  mod_privacy: {}
  mod_private: {}
  mod_pubsub: {}
  mod_push: {}
  mod_push_keepalive: {}
  mod_register:
    ip_access: trusted_network
  mod_roster:
    versioning: true
  mod_s2s_dialback: {}
  mod_shared_roster: {}
  mod_stream_mgmt:
    resend_on_timeout: if_offline
  mod_vcard: {}
  mod_vcard_xupdate: {}
  mod_version:
    show_os: false

Errors from stdout (ejabberdctl foreground)

2021-02-05 19:16:16.420918+03:00 [warning] pubsub.localhost rejected notification for [email protected] (pushnode), disabling push: bad-request (modify)

Bug description

I can't get push-notifications mech to work. I had created socket listener on 127.0.0.1:80 (with Python 3.7) and send stanza through Psi+ console:

<iq id='x-37' type='set'>
  <enable xmlns='urn:xmpp:push:0' jid='pubsub.localhost' node='pushnode'></enable>
</iq>

And get proper:

2021-02-05 19:14:13.830691+03:00 [info] Enabling push notifications for [email protected]/Psi+

But next, when I've sent a message to this contact I get Ejabber error like this:

2021-02-05 19:16:16.318971+03:00 [warning] pubsub.localhost rejected notification for [email protected] (pushnode), disabling push: bad-request (modify)

But my listening echo-script didn't catch anything.

Questions

  • Where and what port Ejabberd had trying to reach to?
  • Where does it documented?
  • What does "rejected notification" mean?

I couldn't find out that in whole Internet. Could someone answer this questions? THANKS FOR ANY HELP!

All 6 comments

Can you try with an actual app first, eg. Conversations from Google Play or Siskin from Apple Store?

Ejabberd doesn't contain module that sends pushes to devices (that communicates with apple/google server), you need to install external component for that. You would need to use address of that service in to make it work, what you did in your example, was just tallking to builtin pubsub module which doesn't know how to send pushes.

Can you try with an actual app first, eg. Conversations from Google Play or Siskin from Apple Store?

What does that mean? I need Ejabber to connect by my own client app not any Siskin or Conversations. That is the point.

Ejabberd doesn't contain module that sends pushes to devices (that communicates with apple/google server), you need to install external component for that. You would need to use address of that service in to make it work, what you did in your example, was just tallking to builtin pubsub module which doesn't know how to send pushes.

Can you link me to the kinda guide? Or hint me some example? Appreciate any help.

The main target audience of the ejabberd "Community Server" is public services who's users use clients not under control of the service operator (such as Monal or Conversations). For that scenario, the service operator doesn't have the credentials required to generate APNS/FCM notifications. Only the client vendor has those. The solution to this use case is to have the client vendor run a service that proxies push notifications triggered on the XMPP server to APNS/FCM. XEP-0357 specifies the communication between the recipient's XMPP server and that "push proxy" (we call it "app server"). The XMPP server side of this extension is implemented in mod_push.

For your use case, i.e. a closed setup where you control both the server and the clients, you don't really need that additional "app server" hop. Technically, you could have ejabberd trigger APNS/FCM notifications directly. As this is usually a commercial use case, the Business Edition supports it, but I'm not aware of a publicly available module.

One workaround might be to search for an existing app server.

@weiss "the Business Edition supports it"
What are conditions for that Biz edition? You pay once and for all or you keep paying based on subscription? What happens on upgrade to new EJ version?

Any documentation on that is appreciated!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

shazvan275 picture shazvan275  路  3Comments

ibrahimkoujar picture ibrahimkoujar  路  3Comments

licaon-kter picture licaon-kter  路  4Comments

lucastimotiofirmino picture lucastimotiofirmino  路  3Comments

ThomasLeister picture ThomasLeister  路  4Comments