Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to host my own push notification gateway ?? #8692

Closed
teko44 opened this issue Oct 28, 2017 · 32 comments
Closed

how to host my own push notification gateway ?? #8692

teko44 opened this issue Oct 28, 2017 · 32 comments

Comments

@teko44
Copy link

teko44 commented Oct 28, 2017

i want to host my own push notification gateway ?
i dont know from where to start or what gateway to selfhost
any help ???

@AmShaegar13
Copy link
Contributor

From the docs

  • Go to “Administration”, then “Push”
  • Set the Enable Gateway to False, then you will use your own Rocket.Chat as gateway instead of the https://rocket.chat server
  • Restart server

Now you should be able to Send a test message. Make sure that you have logged in to the server once, and then closed the app. You should see a test notitication after you pressed the send button.

@teko44
Copy link
Author

teko44 commented Oct 29, 2017

@AmShaegar13
So Rocket.Chat server has it's own gateway so if i implement the server on my own and set push to false, then now i have my own gateway push server ??
im confused -_- am i understand it right ??

@AmShaegar13
Copy link
Contributor

That's how I understand it, yes. I assumed you already have your own instance of RocketChat running. If that's not the case you probably should explain your setup and what you want to achieve a bit more.

@geekgonecrazy
Copy link
Contributor

The gateway is only needed if you would like to use our official apps from the app store. This is the only way we are able to deliver your push notifications to the app.

If you do not want to use our push gateway then you will need to compile your own apps. You don't need a gateway in that case though... you just need to build the apps with the GCM and Apple push information and then set inside of Rocket.Chat

But in no case should you need a push gateway. This is simply a feature to allow us to deliver push notifications to you when you use our official apps.

@flaviovs
Copy link

flaviovs commented Dec 6, 2017

@geekgonecrazy, can you elaborate a bit more about what travels through Rocket.Chat gateways?

I think that most people that self-host their server are interested in maintaining privacy control of the messages exchanged on their RC instances, and it is not clear what actually goes back and forth between self-hosted instances and the RC gateway WRT notifications.

More specifically, are message contents sent to RC servers upon notifications? What exactly is sent to RC server?

Any insight will be appreciated.

[Edit: opened a new issue to track this: #9027]

@rasos
Copy link
Contributor

rasos commented Dec 14, 2017

@arminfelder is working on a push gateway. We need it for our fairchat app, which allows to connect to any RocketChat server, but we can't share private keys for GCM.

@arminfelder
Copy link
Contributor

as @rasos pointed out, I wrote a small pushgateway for RocketChat, please feel free to give me feedback: https://git.fairkom.net/chat/RocketChatMobilePushGateway

@magnetic5355
Copy link

To confirm the instructions here do not work for Google Play Store apps and you have to use the gateway?

https://rocket.chat/docs/administrator-guides/notifications/push-notifications/

@arminfelder
Copy link
Contributor

@caesarcxiv the android application is registering it self with Google Firebase Messaging(formally GCM), by using given credentials, built into the app, the app then sends the received push token to the Rocket.Chat Server you are connected to. The RC server then send notifications using the API key, which is related to the key the app is using, together with the token as recipent to google, which is then sending it to the mobile.
If you have your own RC server and want to use the Rocket.Chat cordova app, you would need to configure your server to forward the notifications to the app developers, as they are the only ones, who are able to send push messages to their app. This is done by setting the push gateway.
If you develop your own app or just build it yourself, you have to set your credentials from Google Firebase to your server.
If you develop your own app, and want other servers to be able to use it, with push, then you need to setup your own gateway, which then has to be used by the other servers..., in that case you can use my small gateway server: https://git.fairkom.net/chat/RocketChatMobilePushGateway

@trongthanh
Copy link
Contributor

Hi @arminfelder, I'm testing out your gateway server https://git.fairkom.net/chat/RocketChatMobilePushGateway but having blocking issues.

I'm receiving a stdout log from the executable rocketChatMobilePushGateway like this:

<!DOCTYPE html>
<html lang=en>
  <meta charset=utf-8>
  <meta name=viewport content="initial-scale=1, minimum-scale=1, width=device-width">
  <title>Error 411 (Length Required)!!1</title>
  <style>
    *{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}body{margin:7% auto 0;max-width:390px;min-height:180px;padding:30px 0 15px}* > body{background:url(//www.google.com/images/errors/robot.png) 100% 5px no-repeat;padding-right:205px}p{margin:11px 0 22px;overflow:hidden}ins{color:#777;text-decoration:none}a img{border:0}@media screen and (max-width:772px){body{background:none;margin-top:0;max-width:none;padding-right:0}}#logo{background:url(//www.google.com/images/branding/googlelogo/1x/googlelogo_color_150x54dp.png) no-repeat;margin-left:-5px}@media only screen and (min-resolution:192dpi){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat 0% 0%/100% 100%;-moz-border-image:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) 0}}@media only screen and (-webkit-min-device-pixel-ratio:2){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat;-webkit-background-size:100% 100%}}#logo{display:inline-block;height:54px;width:150px}
  </style>
  <a href=//www.google.com/><span id=logo aria-label=Google></span></a>
  <p><b>411.</b> <ins>That’s an error.</ins>
  <p>POST requests require a <code>Content-length</code> header.  <ins>That’s all we know.</ins>
Finished, total:1, success:1,failed:0.
Finished, total:1, success:1,failed:0.
Finished, total:1, success:1,failed:0.

I'm compiling the push gateway from source and expose the port 11000 to 80 via Nginx reversed proxy. Unsure if my Nginx reversed proxy config is correct but Content-length header is missing when reaching Google GCM server.

I'm no C++ coder, so just checking with you if your RocketChatMobilePushGateway already pass the Content-length header. I'll keep checking my Nginx config at my side.

@arminfelder
Copy link
Contributor

@trongthanh I just created a branch "debug", with some additional debug information.

For me it looks like there is no data attached at all, because, libcurl is setting the content-length automatically, please check your serverKey.txt file

@trongthanh
Copy link
Contributor

OK, I'll do another round of tests tomorrow. Thanks.

@trongthanh

This comment was marked as resolved.

@arminfelder
Copy link
Contributor

arminfelder commented Apr 18, 2018

@trongthanh I have fixed the issue, it was related to your newline char at the end of the google key, which did destroy the http header, I added a line to remove all \n from the key after reading it into memory.

the key you need is the one called "Server key":
https://console.firebase.google.com/project -> your app -> Project Settings -> Cloud Messaging -> Server key

I think the GCM key should also work, but its legacy...

p.s I also switched on compiler optimizations, now it should run fine with about 1MB of RAM :)

@trongthanh
Copy link
Contributor

@arminfelder Thanks for your quick response. We're making really good progress.

For me, the GCM / FCM push is working now though there is no proper icon, thumbnail for the notification. Maybe I have to fix it in the GooglePushModel.cpp, right now only title and body and a non-related ejson are in the notification object.

Besides, I was too focus on the GCM issue that I didn't notice that push notification doesn't work for Apple / iOS devices either. When I try obmitting /certs/apple/cred.pem file, the executable start just fine. So maybe Apple push is not active?

BTW, when I try to install the Ubuntu package: libcurlpp0-dev as instructed in your README, the package was not found, so I installed libcurl4-openssl-dev which is available for Ubuntu 16.04 LTS instead.

@arminfelder
Copy link
Contributor

@trongthanh I used ubuntu 17.10 on my dev computer, and debian stretch for the Docker image,
I build the gateway to fit my needs for my FairChat app, if you need additions to the pushmessage json, just write me how it should look like, or make a merge request on our gitlab(sign in is possible with github account)

@q210
Copy link

q210 commented Oct 5, 2018

@trongthanh there is a small bug in @arminfelder's gateway affecting iOS push messages, I've created an issue about it and fixed it in this fork https://github.com/q210/RocketChatMobilePushGateway (also fixed Docker file, it can be built now)

@immanuelfodor
Copy link

Hi Everyone, I also needed a self-hosted push gateway but I didn't want to hassle with FCM, so I went on another route. My simple gateway implementation is in Python, uses Apprise to connect to Gotify (or other notification providers), runs in Docker, and it's easy to setup with docker-compose. For a few users, it provides a viable alternative instead of using gateway.rocket.chat and the Google ecosystem. If you're interested, give it a try :) https://github.com/immanuelfodor/rocketchat-push-gateway

@geekgonecrazy
Copy link
Contributor

Important to remind that doing this does require building the mobile apps and getting them distributed to your users

@immanuelfodor
Copy link

Since my solution uses a separate app (e.g. Gotify) to receive the push notifications, you can use the official RC app. The Gotify mobile app uses websockets to get the push messages, and even with excluding it from battery optimization, it doesn't show up in battery usage, no drain or whatsoever for me on Android Pie.

@geekgonecrazy
Copy link
Contributor

geekgonecrazy commented May 8, 2019

True! That's a really cool solution to avoid GCM/FCM thanks for sharing! Looks kinda like ownpush that we've talked to in the past, but looks like gotify started off with all of their source published 👍

Might be worth posting in community creations on forum. Though be sure to point out its for Android only :) I'm sure others would find this really cool

@magicbelette
Copy link
Contributor

For sure that's cool !
Maybe a silly question, but if Gotify mobile app ("simply") uses websockets to get the push messages why Rocket.chat cannot do the same as the Rocket.chat server already support WS ?
I guess that's not easy to code in Rocket mobile client.

@geekgonecrazy
Copy link
Contributor

It’s not that we can’t. But imagine if all of your apps did this. Your battery would be toast. If you have just one service like fcm or gotify running then it’s not bad

@immanuelfodor
Copy link

True! That's a really cool solution to avoid GCM/FCM thanks for sharing! Looks kinda like ownpush that we've talked to in the past, but looks like gotify started off with all of their source published

Might be worth posting in community creations on forum. Though be sure to point out its for Android only :) I'm sure others would find this really cool

Thanks for the kind words! I'm not on the forum, so you can (or please) share it for the benefit of others. If it boosts you community points, karma or whatever, it's a free gift :D

@magicbelette
Copy link
Contributor

It’s not that we can’t. But imagine if all of your apps did this. Your battery would be toast. If you have just one service like fcm or gotify running then it’s not bad

You're right.
But my need is only for "the ultimate team chat software solution", Rocket.chat ;)
For large organization :

  • avoid potential billing with FCM
  • avoid custom mobile client deployment
  • get the notification's content without sending it to FCM for privacy purpose
    Maybe we can have both FCM and WS and let the user choose ?

I remember some kind of popup with Riot that ask me if I want to "toast my battery or not". Matrix uses FCM or long-polling in my memories.

@immanuelfodor
Copy link

Wow, it would be great to have a switch in the app that we only need to flick, and it uses websockets then without any gateway or so. If you don't want the app to be killed by Android, we could just remove it from battery optimizatin just as I did with Gotify. RocketChat can be selfhosted, why use another service when we have everything we need in place? In this context, the whole gateway idea seems like a workaround. I highly support the built-in "alternative" notification idea, it can have a benefit on the privacy side as well (before Gotify, I used to turn off displaying message content for messages going through the official gateway and FCM).

@davewang
Copy link

I need gateway‘s standard, it is there?

@simonhgomes
Copy link

@teko44 We had used a push notifications gateway called: Cloud Alert Messaging Gateway. The Gateway is free to download and they also have a free plan where you can send Unlimited free messages for upto 500 unique devices per month.
In our recent project we had basically used their APIs to integrate with our application and database and notifications were pushed to our customers on event-based actions. We were also able to easily integrate notifications in our android and iOS mobile apps, through their SDK. I think you should give them a try.
The other interesting fact was that their notifications gateway had so many features.

@arminfelder
Copy link
Contributor

I need gateway‘s standard, it is there?

I don't think there is any documentation out there, but you could either watch the packages, or look into the code or Rocketchat or one of the community wirtten gateways mentioned here like:
https://github.com/arminfelder/RocketChatMobilePushGateway
https://github.com/immanuelfodor/rocketchat-push-gateway

@reetp
Copy link

reetp commented Jul 26, 2019

Please - this Issue is closed.

Read he documentation here:

https://rocket.chat/docs/administrator-guides/notifications/push-notifications/

Ask questions in the forums or open.rocket.chat

@jsmithangular
Copy link

Wait, is there any way we can change this gateway? http://prntscr.com/ptih0c
What push notification gateways we can use for that value? Without using a self-configured push notification. Please help! Thanks.

@reetp
Copy link

reetp commented Nov 7, 2019

Please help! Thanks.

Please read my previous comment. Stop asking here as you will get no help here.

Ask questions in the forums or open.rocket.chat
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests