1

I'm trying to add a pushEndpoint to a subscription I'm trying to create in Google's PubSub (https://cloud.google.com/pubsub/) so I'm able to receive push updates from Gmail. The pushEndpoint I'm trying to add is an HTTPS-URL with a port (e.g.: https://developers.example.com:9081/pushEndpoint) but I keep getting Invalid push endpoint given (endpoint=https://developers.briteback.com:9081/mailSyncHandler). Refer to https://cloud.google.com/pubsub/subscriber#create for more information.

So the question is if it's possible to add a port to a pushEndpoint?

Here's the code thats trying to create the subscription:

var rp = require('request-promise');
rp({
   url: 'https://pubsub.googleapis.com/v1/projects/projectId/subscriptions/mailSync',
   method: 'PUT',
   headers: {
     Authorization: 'Bearer accessToken'
   },
   json: {
     topic: 'projects/projectId/topics/mailSync',
     pushConfig: {
       pushEndpoint: 'https://developers.example.com:9081/mailSyncHandler'
     }
   }
 })
 .then(function(response) {
   console.log(response);
   res.send(response);
 })
 .catch(function(err) {
   console.error(err);
   res.status(err.statusCode).send(err.error.error.message);
 });
jwanglof
  • 548
  • 1
  • 5
  • 20
  • Please try adding your push subscription from API explorer and let us know if it works with port specified. Link: https://developers.google.com/apis-explorer/#search/pubsub.projects.subscriptions.create/m/pubsub/v1/pubsub.projects.subscriptions.create – Furhan S. Aug 17 '15 at 13:14
  • The same thing happens in the API explorer. Error message: `Invalid push endpoint given (endpoint=https://developers.example.com:8091/mailSyncHandler). Refer to https://cloud.google.com/pubsub/subscriber#create for more information.`. Status: `INVALID_ARGUMENT` – jwanglof Aug 17 '15 at 13:40
  • Hence its clear from this little experimentation that pubsub does not support pushendpoints with port numbers. Try some kind to re-routing on your pushendpoint to forwarded messages from pubsub to your desired port. – Furhan S. Aug 17 '15 at 14:12
  • Figured that =) Created a simple reverse proxy with node-http-proxy to make it work with our setup – jwanglof Aug 18 '15 at 06:37
  • (Psst..you didn't sanitize all your URLs, if it matters) – Greg M. Krsak Oct 19 '15 at 22:02

1 Answers1

1

So it seems like it's not possible to add a port to a pushEndpoint. What I ended up doing was to create a reverse proxy (with node-http-proxy) that listens on port 443 and forwards /mailSyncHandler to the correct addresses within our network.

jwanglof
  • 548
  • 1
  • 5
  • 20