Open Zeromax opened 3 years ago
Finally I found the root cause of this error. In this case Rocket Chat is not really good in explaining it in documentation and showingg where to find the Issues. I will try to help improve the docs if i find the time.
So the root cause can only be found when watching the logs before rocket chat is started up. To keep things short: I checked out the repo and run latest master build and did the same configuration as on my prod server for debuging and adding additional logs if needed.
I found this log (before the server was ready to use):
I20211031-10:10:51.362(1)? [2021-10-31T09:10:51.358Z] DEBUG (Push/1101 on MAC-C02D41CXMD6M): APN configured
I20211031-10:10:51.363(1)? [2021-10-31T09:10:51.358Z] WARN (Push/1101 on MAC-C02D41CXMD6M): WARNING: Push APN is configured to production mode - but server is running from localhost
I20211031-10:10:51.363(1)? [2021-10-31T09:10:51.359Z] ERROR (Push/1101 on MAC-C02D41CXMD6M): Error trying to initialize APN
I20211031-10:10:51.363(1)? [2021-10-31T09:10:51.359Z] ERROR (Push/1101 on MAC-C02D41CXMD6M): ENAMETOOLONG: name too long, open 'XXXKey starts here'
I configured the APN certs like described in the doc, by putting in the content of it into those fields.
At the end of apn.js
there is this code:
try {
apnConnection = new apn.Provider(options.apn);
} catch (e) {
logger.error('Error trying to initialize APN');
logger.error(e);
}
So in my case apnConnection
will be undefined, because during creating the provider the error ENAMETOOLONG: name too long, open 'XXXKey starts here
occures.
That means later, when sending the test push notification the Error TypeError: Cannot read property 'send' of undefined at sendAPN (app/push/server/apn.js:48:16)
makes sence, because apnConnection
is undefined and calling apnConnection.send()
will lead to this error.
So this is why this error happens. IMO Rocket chat should try to reinitialize apn connection when sending the test push, if apnConnection
is undefined. Also: It would be important to change the note in the beginning to: Any change on this setting page requires a server restart
, this was also not clear to me.
I came up with a solution for this. Instead of paste the cert and key content of the APN connection, I used the file path for it:
And added the files to a folder and link them to the container:
volumes:
- ./certs:/app/apn-certs
After restarting the server, APN push notification works.
I hope this helps to understand the pain of configuring a whitelabel server with APN.
IMO only docs and error output of rocket chat needs to be improved, as it is a real problem to understand what goes wrong and what to change.
Description:
I have a own RocketChat server running. Therefore I configured Push notifications with own Google Firebase Cloud Messaging.
For Android it works fine.
For iOS not.
Steps to reproduce:
Prerequisit: Proper setup for Cloud Messaging in Google console. I only configured APN/Apple for Production. No need for develop.
Expected behavior:
I expected that a Test Push notification was send to my iOS phone and on my Android phone.
Even if sending push notification to iOS fails, I expected, that Android will still get Notifications.
Actual behavior:
Even on iOS or Android this admin user will not get any Push notification.
Others with only Android will still recieve Notifications.
Also when getting normal messages, this user will not get any notification on iOS or Android.
Server Setup Information:
Client Setup Information
Additional context
If I remove the APN tokens in Database from this User directly in MongoDB:
Then this admin user can recieve push notifications again on Android
Relevant logs: