RocketChat / Rocket.Chat

The communications platform that puts data protection first.
https://rocket.chat/
Other
40.62k stars 10.62k forks source link

Push Notifications Not Working #4515

Closed bighair closed 6 years ago

bighair commented 8 years ago

Your Rocket.Chat version: 0.39.0 / Manual CentOS install

I'm using the native Android app downloaded from the Play Store and I'm not getting any push notifications at all.

I've not got any certificates or keys in the Admin > Push settings. I just have push notifications enabled with the standard 'https://rocket.chat' gateway enabled.

Any ideas?

shellster commented 8 years ago

I'm experiencing the same problem. My phone is a Moto Pure X, if it matters. Previous versions worked, but not sure what version stopped working.

TheReal1604 commented 8 years ago

@bighair please try to set the gateway URL to https://gateway.rocket.chat The developers changed the push system URL, maybe the old one is not more functional. Please take attention that you use the latest rocket.chat version also.

bighair commented 8 years ago

@TheReal1604 Thanks, I've tried with the new URL too and still no joy. When I try the 'Send a Test Push to My User' button it pops up saying successfully sent a message to 1 device but I get no message.

I'm going to try upgrading out of hours tonight to see if this makes a difference.

shellster commented 8 years ago

My gateway is set to https://gateway.rocket.chat. I've also tried setting up google push alters via the API. Still no luck. I'm running the latest version of Rocket.Chat.

TheReal1604 commented 8 years ago

@bighair Do you restart your instance after that change?

RichardFoxworthy commented 8 years ago

Push alerts from RC are very flaky. I am still trying to get a crisp and repeatable issue reports, but have been unable to make it work reliably on any of my test and demo instances, which include v0.35, v0.38 and v0.43 of RC

Push alerts seems only to work through using the 'Send a Test Push to my user' button in the Push admin screen AND also being logged into a mobile app using same account, with the app launched, but in background state - I have seen it work in this way for both iOS and Android, but only occasionally, not reliably.

And regardless if the push alert is actually received on mobile device or not, the popup acknowledgement toast will tell me that its successfully sent push alert to 1 or 2 or sometimes more devices - seems to inconsistently pick the number of devices it says it has pushed to.

Push never works when the app is closed.

Push never works on DM or mention.

For push test, I see logs like this: I20161010-16:42:06.417(11) rocketchat:lib debug.js:15 Meteor ➔ method push_test -> userId: 6tZZWMuPYkRkr5857 , arguments: {}

Have tried using the default RC gateway and also using a custom build of cordova app that includes custom certs and keys. Same behaviour in both cases - ie occasional successes, which at least convinces me that the issue is not with the gateway config.

TheReal1604 commented 8 years ago

@RichardFoxworthy Please open a separate issue for this, i think there is something broken at your deployment. For me, the developer push gateway is working fine. There is no reason why you get no push notifications when app is closed because this push messages goes a over a separate infrastructure at Google or Apple (Google GCM and Apple APNS). https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/ApplePushService.html

shellster commented 8 years ago

To add more to my previous message in this thread. When I try to do a push test alert in my admin section, it always says that the Test alert was successfully pushed to three devices. I have three active users in my instance. Push alerts show up for all three of us in the rocket chat desktop app. For the other two users (on Andriod phones), push alerts show up just fine. I am also using an Andriod phone (though running Cyogenmod), and I am the only user who does not receive push alerts on my phone. Push alerts used to work just fine on this phone with Cyogenmod. I have made sure that Rocket Chat is fully updated. Made sure that the the push alert section is correctly setup with my Google API keys, and rebooted Rocket.Chat on the server. Still no luck.

bighair commented 8 years ago

@TheReal1604 sorry for the delayed reply. I've finally managed to get time to upgrade my production server instance of RC and I still have this problem. To recap, I'm now running 0.42.0 and have the Gateway set as https://gateway.rocket.chat. Even after the upgrade and restart I still get no push notifications on my mobile. I get a message stating that a notification has been successfully pushed, but none turns up.

I just need to be clear that I've not made any other changes to the push settings other than the Gateway address (now that's back to the original value as detailed above). I've not added any certs or keys, but I didn't think this was required as I'm using the native Android app. Is that correct?

TheReal1604 commented 8 years ago

@bighair https://github.com/RocketChat/Rocket.Chat/issues/4594

Just to be sure, can you do the same steps as mentioned above? Maybe its a bug then you fill in your own gcm key.. in my deployments i only check the "use Gateway" thingy and all is working fine.

bighair commented 8 years ago

Thanks @TheReal1604 From the ticket you referenced I'm guessing you're suggesting the keys and certs should be empty if I'm using the RC gateway? If so then I've not got them populated. I tried restarting anyway but still no joy. I just have the attached set. screen shot 2016-10-11 at 22 19 15

bighair commented 8 years ago

If it helps I just turned on debug and got this from my logs:

[34mI20161011-22:14:54.901(1) cordova.coffee:153 System ➔ error Error sending push to gateway (0 try) -> { [Error: connect ECONNREFUSED 45.55.199.111:443] code: 'ECONNREFUSED', errno: 'ECONNREFUSED', syscall: 'connect', address: '45.55.199.111', port: 443 } I20161011-22:14:54.907(1) cordova.coffee:157 System ➔ info Trying sending push to gateway again in 100 milliseconds I20161011-22:15:00.100(1) cordova.coffee:153 System ➔ error Error sending push to gateway (1 try) -> { [Error: connect ECONNREFUSED 45.55.199.111:443] code: 'ECONNREFUSED', errno: 'ECONNREFUSED', syscall: 'connect', address: '45.55.199.111', port: 443 } I20161011-22:15:00.101(1) cordova.coffee:157 System ➔ info Trying sending push to gateway again in 1000 milliseconds I20161011-22:15:01.190(1) cordova.coffee:153 System ➔ error Error sending push to gateway (2 try) -> { [Error: connect ECONNREFUSED 45.55.199.111:443] code: 'ECONNREFUSED', errno: 'ECONNREFUSED', syscall: 'connect', address: '45.55.199.111', port: 443 } I20161011-22:15:01.192(1) cordova.coffee:157 System ➔ info Trying sending push to gateway again in 10000 milliseconds I20161011-22:15:11.278(1) cordova.coffee:153 System ➔ error Error sending push to gateway (3 try) -> { [Error: connect ECONNREFUSED 45.55.199.111:443] code: 'ECONNREFUSED', errno: 'ECONNREFUSED', syscall: 'connect', address: '45.55.199.111', port: 443 } I20161011-22:15:11.280(1) cordova.coffee:157 System ➔ info Trying sending push to gateway again in 100000 milliseconds I20161011-22:16:51.373(1) cordova.coffee:153 System ➔ error Error sending push to gateway (4 try) -> { [Error: connect ECONNREFUSED 45.55.199.111:443] code: 'ECONNREFUSED', errno: 'ECONNREFUSED', syscall: 'connect', address: '45.55.199.111', port: 443 } I20161011-22:16:51.374(1) cordova.coffee:157 System ➔ info Trying sending push to gateway again in 1000000 milliseconds I20161011-22:20:34.591(1) Push: send message "@bighair" via query { userId: 'qCQx8rc6g5b4NwkQx' } I20161011-22:20:34.596(1) Push: send to token { gcm: 'eVYi1Z5mByY:APA91bFXMttz0lDCaSKYexlipk7xaOGIGrWbu-6Z-f9p-PhRtvMJxSjyE34b4Qlyw8Ee9W65FJdNL_G8HWxLdEhV3OQR5ohOWK8BXd6ZG9-VEt5eIiAY8MIdA0nyZvfVdpcyFg5p60GE' } I20161011-22:20:34.982(1) cordova.coffee:153 System ➔ error Error sending push to gateway (0 try) -> { [Error: connect ECONNREFUSED 45.55.199.111:443] code: 'ECONNREFUSED', errno: 'ECONNREFUSED', syscall: 'connect', address: '45.55.199.111', port: 443 } I20161011-22:20:34.984(1) cordova.coffee:157 System ➔ info Trying sending push to gateway again in 100 milliseconds I20161011-22:20:35.168(1) cordova.coffee:153 System ➔ error Error sending push to gateway (1 try) -> { [Error: connect ECONNREFUSED 45.55.199.111:443] code: 'ECONNREFUSED', errno: 'ECONNREFUSED', syscall: 'connect', address: '45.55.199.111', port: 443 } I20161011-22:20:35.170(1) cordova.coffee:157 System ➔ info Trying sending push to gateway again in 1000 milliseconds I20161011-22:20:36.261(1) cordova.coffee:153 System ➔ error Error sending push to gateway (2 try) -> { [Error: connect ECONNREFUSED 45.55.199.111:443] code: 'ECONNREFUSED', errno: 'ECONNREFUSED', syscall: 'connect', address: '45.55.199.111', port: 443 } I20161011-22:20:36.263(1) cordova.coffee:157 System ➔ info Trying sending push to gateway again in 10000 milliseconds I20161011-22:20:46.355(1) cordova.coffee:153 System ➔ error Error sending push to gateway (3 try) -> { [Error: connect ECONNREFUSED 45.55.199.111:443] code: 'ECONNREFUSED', errno: 'ECONNREFUSED', syscall: 'connect', address: '45.55.199.111', port: 443 } I20161011-22:20:46.357(1) cordova.coffee:157 System ➔ info Trying sending push to gateway again in 100000 milliseconds

bighair commented 8 years ago

I'm guessing it's something to do with the "ECONNREFUSED"

Sonoma95SS commented 8 years ago

We are getting somewhat the same errors, but different in a way. Hopefully we can get these resolved soon. I'm ready to start using this live with my team.

shellster commented 8 years ago

I don't know if my issue is the same issue. When I turn on debugging and click sent test push, the log shows this:

Push: send message "@[redacted but my username]" via query { userId: '[redacted but my user id]' }
Push: send to token { gcm: '[redacted long gcm token]' }
Push: send to token { gcm: '[redacted long gcm token]' }

No errors in my log, and still no notifications.

engelgabriel commented 7 years ago

Has this been fixed?

bighair commented 7 years ago

Not for me, I'm on v0.49.3 now and still don't get push notifications in my Android app.

I've just tried enabling debug and sending some test messages and I don't get the ECONNREFUSED error anymore. In fact there are no error messages in my log after sending the push test message. As far as my install seems to think, it's been sent successfully. I just don't get any notification on my phone.

shellster commented 7 years ago

I believe the issue has been figured out based on my comments in this thread: https://github.com/RocketChat/Rocket.Chat/issues/5122

It appears that Rocketchat is not rechecking your GCM values after you register a device, so if it ever changes (like when you install a new ROM), you will cease getting notifications. I have to validated this, but if this is indeed the problem, you probably can solve it by cleaning out the entry for your phone in the mongodb and then logging in with the phone app again.

bighair commented 7 years ago

I just uninstalled and reinstalled the app and notifications are working now.

On Wed, 25 Jan 2017, 19:01 shellster, notifications@github.com wrote:

I believe the issue has been figured out based on my comments in this thread: #5122 https://github.com/RocketChat/Rocket.Chat/issues/5122

It appears that Rocketchat is not rechecking your GCM values after you register a device, so if it ever changes (like when you install a new ROM), you will cease getting notifications. I have to validated this, but if this is indeed the problem, you probably can solve it by cleaning out the entry for your phone in the mongodb and then logging in with the phone app again.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/RocketChat/Rocket.Chat/issues/4515#issuecomment-275200284, or mute the thread https://github.com/notifications/unsubscribe-auth/ADEiaMPFa4P9eVFlYkvBWB6XFVlsbyL4ks5rV5wCgaJpZM4KMHAR .

amenk commented 7 years ago

@shellster I also have the problem that I do not receive any pushes anymore, might be since a android update, not sure... Did you find out how to clean the device ID from the mongo db?

amenk commented 7 years ago

App tokens: db.getCollection('_raix_push_app_tokens').find()

amenk commented 7 years ago

Even after reinstalling the app and db.getCollection('_raix_push_app_tokens').remove({userId: "XXXXXXXXXXXXX"}); i do not receive push messages

amenk commented 7 years ago

I was able to send a push via my local rocket.chat dev server, but not the live instance ...

# meteor shell

> RocketChat.settings.get('Push_gateway') 
'https://gateway.rocket.chat'
> service = 'gcm';
'gcm'
> token = 'XXXXXXXXXXX token extracted from mongo db XXXXXXXXXXXXXXXXXX'
> options = { from: 'x', text: 'y', title: 'z' }
{ from: 'x', text: 'y', title: 'z' }
>   const data = {
...         data: {
.....           token: token,
.....           options: options
.....       }
...     };
> HTTP.post(RocketChat.settings.get('Push_gateway') + `/push/${service}/send`, data, function(error, response) { console.log(error); console.log(response); });
>

-> that worked

shellster commented 7 years ago

@amenk I don't really know what solved my issue exactly. I was speculating a bit, above. Things I would recommend:

1) Uninstall the app on your phone, and make sure to delete any cache, then reinstall.

2) Check the debug logs on the server to see what it shows if you still aren't getting alerts.

3) Try creating a new account and logging in with this, and see if that account gets alerts (if it does, it means you probably didn't clear everything in the admin that you needed to).

4) If 3 works, maybe delete your primary account and recreate it?

amenk commented 7 years ago

1+2 I did, it says sending push notification, but it does not get trough... trying to login to meteor shell now on the server to check if it depends on the IP

shellster commented 7 years ago

After doing 1 and cleaning out your push notification in mongo, what happens if you log in through the web browser and try to do a test notification on the server? Does it still show it sending an push to an token? If so, that would let you know that the token's aren't being cleared out in mongo, so you missed something.

amenk commented 7 years ago

Nope, then it says "There are no tokens for this user"

amenk commented 7 years ago

I am doing some more debugging:

curl -H "Content-Type: application/json" -X POST -d '{"token":"xxxxxxxxxxxxxx-xxxxxxxxxxxxxx-","options":{"from":"x","text":"y","title":"z"}}' https://gateway.rocket.chat/push/gcm/send

is working from that server.

We can get the output from the gateway communication by setting the gateway to http://localhost:8888 and running nc -tl 8888 in the shell and press the push-test-button

amenk commented 7 years ago

When I send the exact same output I logged via nc from the same maschine via CURL to gateway.rocket.chat it is working ... that is very strange...

amenk commented 7 years ago

Now after resetting the URL from back from http://localhost:8080 to https://gateway.rocket.chat it started to work - that is very strange. Maybe the gateway setting was not stored properly in the configuration?

TheBelgarion commented 6 years ago

DNS resolution does not seem to work/wrong with the IP 45.55.199.111 ( like on some examples above, but had the same problem)

[root@test01 ~]# wget https://gateway.rocket.chat/ --2018-05-23 18:44:10-- https://gateway.rocket.chat/ Resolving gateway.rocket.chat (gateway.rocket.chat)... 45.55.199.111 Connecting to gateway.rocket.chat (gateway.rocket.chat)|45.55.199.111|:443... NO RESULT

while from another machine [root@test02 ~]# wget https://gateway.rocket.chat/ --2018-05-23 18:45:07-- https://gateway.rocket.chat/ Resolving gateway.rocket.chat (gateway.rocket.chat)... 104.196.189.8 Connecting to gateway.rocket.chat (gateway.rocket.chat)|104.196.189.8|:443... connected. HTTP request sent, awaiting response... 200 OK

Hudell commented 6 years ago

We've recently refactored the notification system so this old issue is no longer relevant. If you run into any problems with notifications please open a new issue.

binaryme commented 6 years ago

I get following error on rocket chat logs when testing push from admin panel:

[159.203.135.193]rocketchat_logger rocketchat_logger.js:278 System ➔ error Error sending push to gateway (3 try) -> TypeError: First argument should be a valid curve name at Object.createSecureContext (_tls_common.js:115:15) at Object.exports.connect (_tls_wrap.js:1048:48) at Agent.createConnection (https.js:111:22) at Agent.createSocket (_http_agent.js:217:26) at Agent.addRequest (_http_agent.js:187:10) at new ClientRequest (_http_client.js:272:16) at Object.request (http.js:39:10) at Object.request (https.js:239:15) at Request.start (/built_app/programs/server/npm/node_modules/meteor/http/node_modules/request/request.js:748:32) at Request.write (/built_app/programs/server/npm/node_modules/meteor/http/node_modules/request/request.js:1498:10) at end (/built_app/programs/server/npm/node_modules/meteor/http/node_modules/request/request.js:546:18) at Immediate. (/built_app/programs/server/npm/node_modules/meteor/http/node_modules/request/request.js:575:7) at runCallback (timers.js:781:20) at tryOnImmediate (timers.js:743:5) at processImmediate [as _immediateCallback] (timers.js:714:5)

what have i tried:

Not iphone nor android is receiving push on mobile devices.