【问题标题】:connection from "spring data solr" to solr in openshift timeout在 openshift 超时中从“spring data solr”连接到 solr
【发布时间】:2025-11-21 14:35:01
【问题描述】:

我在将 spring data solr 连接到在 openshift 上运行的 solr 时遇到问题。

<solr:solr-server id="solrServer"
    url="http://solr-dashapramathi.rhcloud.com/" />

<bean id="solrTemplate" class="org.springframework.data.solr.core.SolrTemplate"
    scope="singleton">
    <constructor-arg ref="solrServer" />
</bean>

是我的配置。我还尝试将 url 设为“http://solr-dashapramathi.rhcloud.com/#/dashapramathi”我在 openshift 上运行 Solr 4.10.1。

错误如下:

IOException occured when talking to server at: http://solr-dashapramathi.rhcloud.com/dashapramathi; nested exception is org.apache.solr.client.solrj.SolrServerException: IOException occured when talking to server at: http://solr-dashapramathi.rhcloud.com/dashapramathi

原因:

org.springframework.data.solr.UncategorizedSolrException: 与服务器交谈时发生 IOException:http://solr-dashapramathi.rhcloud.com/dashapramathi;嵌套异常是 org.apache.solr.client.solrj.SolrServerException: 与服务器交谈时发生 IOException:http://solr-dashapramathi.rhcloud.com/dashapramathi 在 org.springframework.data.solr.core.SolrTemplate.execute(SolrTemplate.java:136) 在 org.springframework.data.solr.core.SolrTemplate.saveBean(SolrTemplate.java:175) 在 org.springframework.data.solr.core.SolrTemplate.saveBean(SolrTemplate.java:169) 在 org.springframework.data.solr.repository.support.SimpleSolrRepository.save(SimpleSolrRepository.java:149)

原因:org.apache.http.conn.ConnectTimeoutException: Connect to solr-dashapramathi.rhcloud.com:80 timed out 在 org.apache.http.conn.scheme.PlainSocketFactory.connectSocket(PlainSocketFactory.java:129)

谁能帮帮我?

【问题讨论】:

  • 当我在本地系统中运行 Solr 时,它按预期工作。

标签: spring solr openshift


【解决方案1】:

根据此处列出的文档http://docs.spring.io/spring-data/solr/docs/1.2.4.RELEASE/reference/html/solr.repositories.html 判断,它似乎试图通过端口 8993 进行连接,这就是为什么会收到超时。

OpenShift 仅允许对 80,8080,443,8443 进行外部连接。对于内部齿轮连接,您可以根据以下 OpenShift Doc https://help.openshift.com/hc/en-us/articles/202185874 更改连接到更多端口的内容。

【讨论】:

    【解决方案2】:

    我遇到了同样的问题,我已经设法通过更改 Solr 服务器定义中的超时来解决它。 因此,对于您的情况,它将是:

    > <solr:solr-server id="solrServer"
    >     url="http://solr-dashapramathi.rhcloud.com/" timeout="1000"/>
    

    或者您可以设置更高的超时值,具体取决于您的连接。

    在 Spring Data Solr 的文档中,8993 端口可能是托管 Solr 的应用程序服务器运行的端口。

    【讨论】: