st3fan / dovecot-xaps-daemon

MIT License
164 stars 37 forks source link

xapsd does not send push notify to Apple push servers #50

Closed bmansvk closed 4 years ago

bmansvk commented 4 years ago

I have an issue with xapsd-daemon. I have configured xapsd-daemon with xapsd-plugin-dovecot under RHEL8.

When mail arrives, I can see, that dovecot is notifying xapsd-daemon. Log output:

DEBU[252097] Accepted a connection
DEBU[252097] Received request: NOTIFY dovecot-username="user@domain.sk"      dovecot-mailbox="INBOX" events=("MessageNew")
DEBU[252097] Returning success:

But it seems that xapsd-daemon does not send message to Apple push servers.

But sometimes it works. Log output:

ESC[37mDEBUESC[0m[5820] Checking all delayed APNS
ESC[37mDEBUESC[0m[5820] Registration 510C4AF2-9B42-42C1-B1C2-7A07111D592E / 96D39E1470983D48389F11FA7EB5265889ECCBB0D140BFA59F8F619A5C553617 has been waiting for 4.628962097s
ESC[37mDEBUESC[0m[5840] Checking all delayed APNS
ESC[37mDEBUESC[0m[5840] Registration 510C4AF2-9B42-42C1-B1C2-7A07111D592E / 96D39E1470983D48389F11FA7EB5265889ECCBB0D140BFA59F8F619A5C553617 has been waiting for 24.629003552s
ESC[37mDEBUESC[0m[5860] Checking all delayed APNS
ESC[37mDEBUESC[0m[5860] Registration 510C4AF2-9B42-42C1-B1C2-7A07111D592E / 96D39E1470983D48389F11FA7EB5265889ECCBB0D140BFA59F8F619A5C553617 has been waiting for 44.629642389s
ESC[37mDEBUESC[0m[5860] Sending notification to 510C4AF2-9B42-42C1-B1C2-7A07111D592E / 96D39E1470983D48389F11FA7EB5265889ECCBB0D140BFA59F8F619A5C553617
ESC[37mDEBUESC[0m[5880] Checking all delayed APNS

It seems that notification is send when registration message appears before notification message.

My xapsd.json:

{
  "Users": {
    "user": {
      "Accounts": {
        "510C4AF2-9B42-42C1-B1C2-7A07111D592E": {
          "DeviceToken": "96D39E1470983D48389F11FA7EB5265889ECCBB0D140BFA59F8F619A5C553617",
          "Mailboxes": [
            "INBOX",
            "Sent"
          ],
          "RegistrationTime": "2020-03-28T12:07:41.066630532+01:00"
        }
      }
    }
  }
}

Probability ratio, that PUSH message is delivered is around 2-3%. Most of the emails does not trigger PUSH. Does anybody know what is the issue?

freswa commented 4 years ago

The device has to be registered to receive push notifications. The first message only indicates an event in dovecot that COULD lead to a APN.

bmansvk commented 4 years ago

Sorry "freeswa", I didn't understand your answer. I have my device registered to xapsd (see above xapsd.json). Dovecot always notifies xapsd about new mail, then xapsd should send APNS notification to my device. But this happens at most in 2-3% of new mails.

Why xapsd does not send APNS notification to Apple Push gateway (no "sending notification" message).

freswa commented 4 years ago

You wrote:

It seems that notification is send when registration message appears before notification message.

But that's a prerequisite. Your json also implies that the user who registered on the IMAP connection is not the same as the INBOX owner.

bmansvk commented 4 years ago

Thanks for the clue. Dovecot sometimes send notification to xapsd with username as "username", sometimes as "username@domain.com". I don't know why. But I modified dovecot user to login as "username@domain.com", not as "username" which I had this configured before. Now it works...

freswa commented 4 years ago

@bmansvk Did you set xaps_user_lookup in you dovecot config?

bmansvk commented 4 years ago

No I didn't. I was not aware of this configuration item. Sometimes dovecot notifies xapsd as "user", sometimes as "user@domain.com".

I changed dovecot to login user to IMAP as user@domain.com and now each time dovecot notifies xapsd as user@domain.com.

Maybe xaps_user_lookup solves the issue. But I was not aware of this config item...

freswa commented 4 years ago

Ok, thanks for reporting back :)