我试图通过在POSTMAN中请求GET来检查是否收到数据。但显示出这样的错误

时间:2018-06-02 04:05:17

标签: firebase postman google-cloud-functions

邮差错误。

无法得到任何回复 连接到http://108.59.80.67/elasticsearch/posts/post/_search?q= *时出错。 为什么会发生这种情况: 服务器无法发送响应: 确保后端正常工作 自签名SSL证书被阻止: 通过在设置>中关闭“SSL证书验证”来解决此问题。一般 代理配置不正确 确保在设置>中正确配置了代理。代理 请求超时: 在设置中更改请求超时>一般

Firebase错误

RequestError: Error: connect ETIMEDOUT 108.59.80.67:80
    at new RequestError (/user_code/node_modules/request-promise/node_modules/request-promise-core/lib/errors.js:14:15)
    at Request.plumbing.callback (/user_code/node_modules/request-promise/node_modules/request-promise-core/lib/plumbing.js:87:29)
    at Request.RP$callback [as _callback] (/user_code/node_modules/request-promise/node_modules/request-promise-core/lib/plumbing.js:46:31)
    at self.callback (/user_code/node_modules/request/request.js:185:22)
    at emitOne (events.js:96:13)
    at Request.emit (events.js:188:7)
    at Request.onRequestError (/user_code/node_modules/request/request.js:877:8)
    at emitOne (events.js:96:13)
    at ClientRequest.emit (events.js:188:7)
    at Socket.socketErrorListener (_http_client.js:310:9)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:188:7)
    at emitErrorNT (net.js:1296:8)
    at _combinedTickCallback (internal/process/next_tick.js:80:11)
    at process._tickDomainCallback (internal/process/next_tick.js:128:9)

Javascript代码

    const functions = require('firebase-functions');

    const request = require('request-promise')

    exports.indexPostsToElastic = functions.database.ref('/posts/{post_id}')
    .onWrite((change,context) => {
    let postData = change.after.val();
    let post_id = context.params.post_id;

    console.log('Indexing post:', postData);

    let elasticSearchConfig = functions.config().elasticsearch;
    let elasticSearchUrl = elasticSearchConfig.url + 'posts/post/' + 
     post_id;
    let elasticSearchMethod = postData ? 'POST' : 'DELETE';

    let elasticSearchRequest = {
        method: elasticSearchMethod,
        url: elasticSearchUrl,
        auth:{
            username: elasticSearchConfig.username,
            password: elasticSearchConfig.password,
        },
        body: postData,
        json: true
      };

      return request(elasticSearchRequest).then(response => {
         console.log("ElasticSearch response", response);
         return null;
      });
      });

0 个答案:

没有答案