我在一个虚拟网络中有一个Web应用程序和一个elasticsearch集群。 Web应用程序位于一个azure目录上,而elasticsearch集群位于另一个目录/订阅上。由于bizspark订阅规则(5个账户每个150美元),我不能将它们放在同一个目录中。
由于这个原因,我无法将Web应用程序连接到具有Point to site的虚拟网络,因为我可以理解。 因此,我在端口9200的虚拟网络防火墙中打开了流量。它可以在连接到elasticsearch集群的Web应用程序中进行索引和搜索。但有时候只是?! 偶尔我得到这个错误:
连接尝试失败,因为连接方没有 在一段时间后正确回应,或建立连接 失败,因为已连接的主机无法响应x.x.x.x:9200
我有时会从同一个webb应用程序中的Web作业中收到此错误。
是否存在阻止我与elasticsearch连接的内容? 如果我更改了我的网络应用程序的计划(例如标准S1到S1或反之亦然),它将再次开始工作。但是过了一会儿我就被阻止了。
答案 0 :(得分:0)
Martin Laarman写道。 SetTcpKeepAlive就是问题所在。 NEST使用EnableTcpKeepAlive()方法在ConnnectionConfiguration中实现了这一点。 我不知道调用EnableTcpKeepAlive的参数是什么。我现在设定的值似乎正常。
public static ElasticClient ElasticClient
{
get
{
var uri = new Uri(ConfigurationManager.AppSettings["ElasticSearchUrl"]);
var setting = new ConnectionSettings(uri);
setting.SetDefaultIndex("myIndex");
var connectionConfiguration = new ConnectionConfiguration(uri);
connectionConfiguration.EnableTcpKeepAlive(200000, 200000);
var client = new ElasticClient(setting, new HttpConnection(connectionConfiguration));
return client;
}
}