在 Rails 中使用 Sunspot 和 Solr 拒绝连接 [英] Connection refused using Sunspot and Solr in Rails

查看:60
本文介绍了在 Rails 中使用 Sunspot 和 Solr 拒绝连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了一个问题,当我尝试使用 sunspot_rails 执行搜索时出现 ECONNREFUSED 错误.宝石(sunspot_rails 和 sunspot_solr)似乎都安装正确.我正在运行 1.3.3 版本,并且服务器运行正常.

I'm having an issue wherein I get an ECONNREFUSED error when I try to perform a search using sunspot_rails. The gems (sunspot_rails and sunspot_solr) both seem to be installed properly. I'm running version 1.3.3 and I have the server running correctly.

我找到了另一篇关于此的帖子,但该帖子仅建议启动 sunspot solr 服务器.我确实这样做了,但错误仍然存​​在.

I've found another post about this, but the post only recommended starting the sunspot solr server. I've definitely done that, but the error persists.

我认为问题出在服务器所在的端口上.当我查看 RAILS_ENV=development rake sunspot:solr:run 的输出时,它显示服务器正在端口 8983 上运行.我也试过命令 RAILS_ENV=production rake sunspot:solr:run 有同样的效果.

I believe the problem is due to the port the server is on. When I look at the output from RAILS_ENV=development rake sunspot:solr:run, it shows that the server is running on port 8983. I've also tried the command RAILS_ENV=production rake sunspot:solr:run with the same effect.

如果我检查 sunspot.yml 配置文件,它会显示以下内容:

If I examine the sunspot.yml config file, it shows the following:

production:
  solr:
    hostname: localhost
    port: 8983
    log_level: WARNING

development:
  solr:
    hostname: localhost
    port: 8982
    log_level: INFO

test:
  solr:
    hostname: localhost
    port: 8981
    log_level: WARNING

请注意,应该在端口 8982 上进行开发,但无论我做什么,它似乎都在端口 8983 上不断重新启动服务器代码>.知道这是怎么发生的吗?

Notice that it's supposed to be on port 8982 for development, but no matter what I do it seems to keep restarting the server on port 8983. Any idea how this could be happening?

谢谢!

更新:我发现了一个潜在的原因.在我的项目文件夹中,文件 /solr/conf/scripts.conf 包含以下内容:solr_port=8983.无论 Rails 环境处于活动状态,这似乎都意味着一个硬编码的端口.

Update: I've found a potential cause. In my project folder, the file /solr/conf/scripts.conf contains the following: solr_port=8983. This seems to imply a hardcoded port no matter what Rails environment is active.

推荐答案

原来是 Sunspot 中的一个错误.这是我提交完整描述的问题的链接:

Turns out it was a bug in Sunspot. Here's a link to the issue I filed for a full description:

https://github.com/sunspot/sunspot/issues/262

我的解决方法是编辑 .yml 文件并将所有端口(测试、开发和生产)更改为 8983.

My workaround was to edit the .yml file and change all ports (test, development, and production) to 8983.

这篇关于在 Rails 中使用 Sunspot 和 Solr 拒绝连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆