首页 > 解决方案 > 我正在尝试通过在 POSTMAN 中请求 GET 来检查是否接收到数据。但是显示这样的错误

问题描述

邮递员错误。

无法得到任何响应连接到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;
      });
      });

标签: firebasepostmangoogle-cloud-functions

解决方案


推荐阅读