firebase - 我正在尝试通过在 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;
});
});
解决方案
推荐阅读
- python - 为什么第二个嵌套 for 循环在迭代期间跳过重复值?
- bash - 子shell中使用的“basename”返回“command not found”
- javascript - 在 Node.js(电子应用程序)中渲染没有框架的 PDF
- swift - 通过 viewDidAppear() 或 viewWillLayoutSubviews() 设置角半径?
- roblox - Roblox - 虽然测试桁架在我将它们拖入时工作,但是当我使用脚本设置所有东西时,我无法爬上它
- scala - 带有 java 库的 Scala gradle 控制台应用程序
- java - CrudRepository 和 RedisTemplate 的 HashOperations 的区别
- android - 活动上下文之间的差异
- c# - 在列表中添加元素会引发 ArgumentOutOfRangeException
- prolog - 规则 CLIPS 到 PROLOG