Connection refused using Sunspot and Solr in Rails

梦想与她 提交于 2020-01-30 06:24:26

问题


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.

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.

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.

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

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?

Thanks!

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.


回答1:


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

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



来源:https://stackoverflow.com/questions/11565149/connection-refused-using-sunspot-and-solr-in-rails

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!