如何延长 SolrConnection 中的超时? (SolrConnectionException:操作已超时)

发布于 2024-12-10 13:36:50 字数 2208 浏览 1 评论 0原文

如何扩展/修改 SolrConnection 对象的超时值?

我有一个长时间运行的优化操作,该操作似乎未在提供的默认连接超时内完成。我正在使用的操作是 ISolrOperations.Optimize()。我没有看到任何直接使用 ISolrOperations 对象增加超时的选项。

我使用 Castle Windsor IoC 容器进行实例化,以便拥有多个核心。

以下是完整的堆栈跟踪:

SolrNet.Exceptions.SolrConnectionException: The operation has timed out ---> System.Net.WebException: The operation has timed out
   at System.Net.HttpWebRequest.GetResponse()
   at HttpWebAdapters.Adapters.HttpWebRequestAdapter.GetResponse() in c:\prg\SolrNet\svn\HttpWebAdapters\Impl\HttpWebRequestAdapter.cs:line 36
   at SolrNet.Impl.SolrConnection.GetResponse(IHttpWebRequest request) in c:\prg\SolrNet\svn\SolrNet\Impl\SolrConnection.cs:line 201
   at SolrNet.Impl.SolrConnection.PostStream(String relativeUrl, String contentType, Stream content, IEnumerable`1 parameters) in c:\prg\SolrNet\svn\SolrNet\Impl\SolrConnection.cs:line 113
   --- End of inner exception stack trace ---
   at SolrNet.Impl.SolrConnection.PostStream(String relativeUrl, String contentType, Stream content, IEnumerable`1 parameters) in c:\prg\SolrNet\svn\SolrNet\Impl\SolrConnection.cs:line 121
   at SolrNet.Impl.SolrConnection.Post(String relativeUrl, String s) in c:\prg\SolrNet\svn\SolrNet\Impl\SolrConnection.cs:line 87
   at SolrNet.Commands.OptimizeCommand.Execute(ISolrConnection connection) in c:\prg\SolrNet\svn\SolrNet\Commands\OptimizeCommand.cs:line 76
   at SolrNet.Impl.SolrBasicServer`1.Send(ISolrCommand cmd) in c:\prg\SolrNet\svn\SolrNet\Impl\SolrBasicServer.cs:line 96
   at SolrNet.Impl.SolrBasicServer`1.SendAndParseHeader(ISolrCommand cmd) in c:\prg\SolrNet\svn\SolrNet\Impl\SolrBasicServer.cs:line 106
   at SolrNet.Impl.SolrBasicServer`1.Optimize(CommitOptions options) in c:\prg\SolrNet\svn\SolrNet\Impl\SolrBasicServer.cs:line 69
   at SolrNet.Impl.SolrServer`1.Optimize() in c:\prg\SolrNet\svn\SolrNet\Impl\SolrServer.cs:line 206
   at NationalLaborRelations.SearchAgent.SearchAgentBase.Optimize(ISolrOperations`1 s) in C:\PROJECTS\NLRB\Search\SearchAgent\SearchAgent\SearchAgentBase.cs:line 354

请注意,优化确实成功发生,但 SolrNet 不会等待它完成才抛出此错误。

How do I extend/modify the timeout value used for the SolrConnection object?

I have a long-running optimize operation that does not appear to complete within the default connection timeout provided. The operation I am using is ISolrOperations<?>.Optimize(). I do not see any options for increasing the timeout using the ISolrOperations object directly.

I am using the Castle Windsor IoC container for instantiation in order to have multiple cores.

Here is the full stacktrace:

SolrNet.Exceptions.SolrConnectionException: The operation has timed out ---> System.Net.WebException: The operation has timed out
   at System.Net.HttpWebRequest.GetResponse()
   at HttpWebAdapters.Adapters.HttpWebRequestAdapter.GetResponse() in c:\prg\SolrNet\svn\HttpWebAdapters\Impl\HttpWebRequestAdapter.cs:line 36
   at SolrNet.Impl.SolrConnection.GetResponse(IHttpWebRequest request) in c:\prg\SolrNet\svn\SolrNet\Impl\SolrConnection.cs:line 201
   at SolrNet.Impl.SolrConnection.PostStream(String relativeUrl, String contentType, Stream content, IEnumerable`1 parameters) in c:\prg\SolrNet\svn\SolrNet\Impl\SolrConnection.cs:line 113
   --- End of inner exception stack trace ---
   at SolrNet.Impl.SolrConnection.PostStream(String relativeUrl, String contentType, Stream content, IEnumerable`1 parameters) in c:\prg\SolrNet\svn\SolrNet\Impl\SolrConnection.cs:line 121
   at SolrNet.Impl.SolrConnection.Post(String relativeUrl, String s) in c:\prg\SolrNet\svn\SolrNet\Impl\SolrConnection.cs:line 87
   at SolrNet.Commands.OptimizeCommand.Execute(ISolrConnection connection) in c:\prg\SolrNet\svn\SolrNet\Commands\OptimizeCommand.cs:line 76
   at SolrNet.Impl.SolrBasicServer`1.Send(ISolrCommand cmd) in c:\prg\SolrNet\svn\SolrNet\Impl\SolrBasicServer.cs:line 96
   at SolrNet.Impl.SolrBasicServer`1.SendAndParseHeader(ISolrCommand cmd) in c:\prg\SolrNet\svn\SolrNet\Impl\SolrBasicServer.cs:line 106
   at SolrNet.Impl.SolrBasicServer`1.Optimize(CommitOptions options) in c:\prg\SolrNet\svn\SolrNet\Impl\SolrBasicServer.cs:line 69
   at SolrNet.Impl.SolrServer`1.Optimize() in c:\prg\SolrNet\svn\SolrNet\Impl\SolrServer.cs:line 206
   at NationalLaborRelations.SearchAgent.SearchAgentBase.Optimize(ISolrOperations`1 s) in C:\PROJECTS\NLRB\Search\SearchAgent\SearchAgent\SearchAgentBase.cs:line 354

Note that the optimization does happen successfully, but that SolrNet does not wait for it to complete before throwing this error.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

并安 2024-12-17 13:36:50

您可以安全地忽略此超时。正如您已经发现的,该命令无论如何都能在 Solr 上成功运行。

或者,如果您想设置连接超时,您可以使用 Windsor 中的组件模型事件进行配置:

var c = new WindsorContainer();
c.Kernel.ComponentModelCreated += model => {
    if (model.Implementation == typeof(SolrConnection))
        model.Parameters.Add("Timeout", "200000");
};
c.AddFacility("solr", new SolrNetFacility("http://localhost:8983/solr")); // or whatever

超时值以毫秒表示。

You can safely ignore this timeout. As you already have found out, the command runs successfully on Solr anyway.

Or if you want to set the connection timeout you can configure it with a component model event in Windsor:

var c = new WindsorContainer();
c.Kernel.ComponentModelCreated += model => {
    if (model.Implementation == typeof(SolrConnection))
        model.Parameters.Add("Timeout", "200000");
};
c.AddFacility("solr", new SolrNetFacility("http://localhost:8983/solr")); // or whatever

Timeout value is expressed in milliseconds.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文