我尝试在订阅中添加pushEndpoint我试图在Google的PubSub(https://cloud.google.com/pubsub/)中创建,以便我能够从Gmail中。我尝试添加的pushEndpoint是带有端口的HTTPS-URL(例如:https://developers.example.com:9081/pushEndpoint),但我不断获得Invalid push endpoint given (endpoint=https://developers.briteback.com:9081/mailSyncHandler). Refer to https://cloud.google.com/pubsub/subscriber#create for more information.
所以问题是,是否可以将一个端口添加到pushEndpoint?
以下是尝试创建订阅的代码:
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);
});
答案 0 :(得分:1)
因此似乎无法向pushEndpoint添加端口。我最终做的是创建一个反向代理(使用node-http-proxy),它侦听端口443并将/ mailSyncHandler转发到我们网络中的正确地址。