elasticsearch - 从 Azure 函数执行时,Nest 无法写入 ES
问题描述
我确实有 azure 函数,它监听事件并将数据写入 ES,但随机失败。
Exception while executing function: ElasticSearchIndexer Invalid NEST response built from a unsuccessful low level call on POST: /_bulk
# Invalid Bulk items:
# Audit trail of this API call:
- [1] AllNodesDead: Took: 00:00:00
- [2] Resurrection: Node: http://ip:9200/ Took: 00:00:00
- [3] PingFailure: Node: http://ip:9200/ Exception: PipelineException Took: 00:00:02.0095670
# OriginalException: Elasticsearch.Net.ElasticsearchClientException: Failed to ping the specified node.. Call: Status code unknown from: HEAD / ---> Elasticsearch.Net.PipelineException: Failed to ping the specified node. ---> Elasticsearch.Net.PipelineException: An error occurred trying to read the response from the specified node. ---> System.Net.WebException: The request was aborted: The request was canceled.
at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
at System.Threading.Tasks.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar, Func`2 endFunction, Action`1 endAction, Task`1 promise, Boolean requiresSynchronization)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Elasticsearch.Net.HttpWebRequestConnection.<RequestAsync>d__5`1.MoveNext()
--- End of inner exception stack trace ---
at Elasticsearch.Net.RequestPipeline.<PingAsync>d__65.MoveNext()
--- End of inner exception stack trace ---
at Elasticsearch.Net.RequestPipeline.<PingAsync>d__65.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Elasticsearch.Net.Transport`1.<PingAsync>d__21.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Elasticsearch.Net.Transport`1.<PingAsync>d__21.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Elasticsearch.Net.Transport`1.<RequestAsync>d__15`1.MoveNext()
--- End of inner exception stack trace ---
# Audit exception in step 3 PingFailure:
Elasticsearch.Net.PipelineException: An error occurred trying to read the response from the specified node. ---> System.Net.WebException: The request was aborted: The request was canceled.
at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
at System.Threading.Tasks.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar, Func`2 endFunction, Action`1 endAction, Task`1 promise, Boolean requiresSynchronization)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Elasticsearch.Net.HttpWebRequestConnection.<RequestAsync>d__5`1.MoveNext()
--- End of inner exception stack trace ---
at Elasticsearch.Net.RequestPipeline.<PingAsync>d__65.MoveNext()
# Request:
<Request stream not captured or already read to completion by serializer. Set DisableDirectStreaming() on ConnectionSettings to force it to be set on the response.>
# Response:
<Response stream not captured or already read to completion by serializer. Set DisableDirectStreaming() on ConnectionSettings to force it to be set on the response.>
我在 DI 注册。
var uris = FlymarkAppSettings.Instance.ElasticServerConnection.Split(';').Select(url => new Uri(url));
var settings = new ConnectionSettings(new StaticConnectionPool(uris));
#if DEBUG
settings.EnableDebugMode();
#endif
builder.Register(c => new ElasticClient(settings))
.As<IElasticClient>()
.SingleInstance();
解决方案
推荐阅读
- java - 如何使用 Spring Data 通过哈希查询 DynamoDB 表
- java - 在junit中断言arrayList内容时出现断言错误
- node.js - 使用 ajax 从网络服务器获取响应
- python - 如何从互联网访问 jupyter-kernel-gateway Rest api?
- nginx - 文件夹中博客的 nginx 重写解决了永久链接而不是文件
- laravel - Laravel 的范围问题
- javascript - 在 Vue.js 中选择不显示选项
- android - 编号选择器在 Recyclerview 中不起作用
- google-sheets - 修改脚本以在每次进行编辑时将数据验证从列表和编辑该数据验证的时间戳复制到新行
- html - 如何从谷歌地图中抓取地址信息?