Riddle::ConnectionError

659 views
Skip to first unread message

stasch

unread,
Nov 11, 2009, 11:38:07 PM11/11/09
to Thinking Sphinx
My web site consists of one database server and three front end web
servers. I am trying to set up thinking-sphinx to share the index
across all of the servers. I have successfully installed the gem on
the database server, configured it, created the indexes and everything
is working fine from both the Rails console and from a back end rails
CMS app that resides on the database server.

I then installed the gem on one of the web servers and configured it
as follows:

production:
address: <ip of database server>
port: 3313
pid_file: /opt/local/var/db/sphinx/log/searchd.pid
searchd_file_path: /opt/local/var/db/sphinx
max_matches: 10000
mem_limit: 256M
bin_path: /usr/local/bin

This is identical to the configuration on the database server except
for the address parameter. When I attempt to do a search from the
Rails console, I get the following error:

Riddle::ConnectionError: Connection to 70.32.120.23 on 3313 failed.
Connection refused - connect(2)
from /usr/local/lib/ruby/gems/1.8/gems/riddle-1.0.0/lib/riddle/
client.rb:500:in `initialise_socket'
from /usr/local/lib/ruby/gems/1.8/gems/riddle-1.0.0/lib/riddle/
client.rb:479:in `initialise_connection'
from /usr/local/lib/ruby/gems/1.8/gems/riddle-1.0.0/lib/riddle/
client.rb:441:in `open_socket'
from /usr/local/lib/ruby/gems/1.8/gems/riddle-1.0.0/lib/riddle/
client.rb:469:in `connect'
from /usr/local/lib/ruby/gems/1.8/gems/riddle-1.0.0/lib/riddle/
client.rb:519:in `request'
from /usr/local/lib/ruby/gems/1.8/gems/riddle-1.0.0/lib/riddle/
client.rb:192:in `run'
from /usr/local/lib/ruby/gems/1.8/gems/riddle-1.0.0/lib/riddle/
client.rb:299:in `query'
from /usr/local/lib/ruby/gems/1.8/gems/thinking-sphinx-1.3.3/
lib/thinking_sphinx/search.rb:235:in `populate'
from /usr/local/lib/ruby/gems/1.8/gems/thinking-sphinx-1.3.3/
lib/thinking_sphinx/search.rb:329:in `call'
from /usr/local/lib/ruby/gems/1.8/gems/thinking-sphinx-1.3.3/
lib/thinking_sphinx/search.rb:329:in `retry_on_stale_index'
from /usr/local/lib/ruby/gems/1.8/gems/thinking-sphinx-1.3.3/
lib/thinking_sphinx/search.rb:232:in `populate'
from /usr/local/lib/ruby/gems/1.8/gems/thinking-sphinx-1.3.3/
lib/thinking_sphinx/search.rb:96:in `method_missing'
from /usr/local/lib/ruby/1.8/irb.rb:302:in `output_value'
from /usr/local/lib/ruby/1.8/irb.rb:151:in `eval_input'
from /usr/local/lib/ruby/1.8/irb.rb:263:in `signal_status'
from /usr/local/lib/ruby/1.8/irb.rb:147:in `eval_input'
from /usr/local/lib/ruby/1.8/irb.rb:146:in `eval_input'
from /usr/local/lib/ruby/1.8/irb.rb:70:in `start'
from /usr/local/lib/ruby/1.8/irb.rb:69:in `catch'
from /usr/local/lib/ruby/1.8/irb.rb:69:in `start'

Is there something else that I have to do to make this work? Or am I
misunderstanding how to set up a distributed index? Should I be
running the indexer on the web server as well? Please forgive my
ignorance. Any help would be appreciated.

Stan Shore

James Healy

unread,
Nov 11, 2009, 11:51:47 PM11/11/09
to thinkin...@googlegroups.com
stasch wrote:
> Is there something else that I have to do to make this work? Or am I
> misunderstanding how to set up a distributed index? Should I be
> running the indexer on the web server as well? Please forgive my
> ignorance. Any help would be appreciated.

This is a guess, but it's possible your sphinx daemon on the database
server is binding to localhost only.

Does your sphinx config file have 'address = 127.0.0.1' in it? If so,
try adding "address: database.ip.address" to sphinx.yml and regenerating
your configs.

-- James Healy <ji...@deefa.com> Thu, 12 Nov 2009 15:51:26 +1100

stasch

unread,
Nov 12, 2009, 1:32:16 AM11/12/09
to Thinking Sphinx
That did it! I actually didn't have any address specified, so I guess
it defaulted to localhost. Once I put the ip of the database server
into the configuration it worked. Thanks so much James.

Stan Shore

stasch

unread,
Nov 12, 2009, 2:22:38 AM11/12/09
to Thinking Sphinx
Sorry, but not quite done yet. I was so relieved that searches were
working in the console that I opened up the search bar on the web
site. Guess what. Same connection error when the search was
initiated via the web site. How can the console work but not the
application? Weird!

Thanks for any help.

Stan

stasch

unread,
Nov 12, 2009, 2:28:15 AM11/12/09
to Thinking Sphinx
A little more info: I'm running the web server with Apache and
phusion passenger 2.0.3.

On Nov 11, 10:32 pm, stasch <stash...@gmail.com> wrote:

James Healy

unread,
Nov 12, 2009, 2:46:33 AM11/12/09
to thinkin...@googlegroups.com
stasch wrote:
> Sorry, but not quite done yet. I was so relieved that searches were
> working in the console that I opened up the search bar on the web
> site. Guess what. Same connection error when the search was
> initiated via the web site. How can the console work but not the
> application? Weird!

Did you update the sphinx.yml on both your web servers and the db
server? If so, have you restarted the rails processes so they detect the
new address to connect to the sphinx daemon on?

-- James Healy <ji...@deefa.com> Thu, 12 Nov 2009 18:30:49 +1100

Pat Allan

unread,
Nov 12, 2009, 4:33:29 AM11/12/09
to thinkin...@googlegroups.com
Also, are you running the rake tasks and script/console as the same
user that owns the web site files? (instead of, say, root).

--
Pat

stasch

unread,
Nov 12, 2009, 8:10:19 PM11/12/09
to Thinking Sphinx
I checked both sphinx.yml and both production.sphinx.conf and the ip
addresses and ports were declared properly. On the database server I
ran a rake ts:rebuild. Then I bounced the server (Apache w/phusion
passenger). Then I went to one of the front end servers, ran rake
ts:config again, and bounced that server.

When I go into the console I can search both of my models with
impunity. When I go to the search bar on the web server and enter the
same search term I was using in the console I still get the connection
refused error.

And I definitely ran the rake tasks and the rails console using the
same user as the owner of environment.rb. According to the phusion
passenger documentation, the owner of environment.rb becomes the web
user.

Any other ideas?

Stan

Pat Allan

unread,
Nov 12, 2009, 8:21:28 PM11/12/09
to thinkin...@googlegroups.com
Can you debug what the following values are via browser somehow?
ThinkingSphinx::Configuration.instance.port
ThinkingSphinx::Configuration.instance.address

--
Pat

stasch

unread,
Nov 12, 2009, 8:29:25 PM11/12/09
to Thinking Sphinx
I checked both sphinx.yml and both production.sphinx.conf and the ip
addresses and ports were declared properly. On the database server I
ran a rake ts:rebuild. Then I bounced the server (Apache w/phusion
passenger). Then I went to one of the front end servers, ran rake
ts:config again, and bounced that server.

When I go into the console I can search both of my models with
impunity. When I go to the search bar on the web server and enter the
same search term I was using in the console I still get the connection
refused error.

And I definitely ran the rake tasks and the rails console using the
same user as the owner of environment.rb. According to the phusion
passenger documentation, the owner of environment.rb becomes the web
user.

Any other ideas?

Stan

On Nov 12, 1:33 am, Pat Allan <p...@freelancing-gods.com> wrote:
Message has been deleted

stasch

unread,
Nov 12, 2009, 9:31:27 PM11/12/09
to Thinking Sphinx
As expected they are 3313 and 70.32.120.23.

Stan
Message has been deleted

stasch

unread,
Nov 12, 2009, 9:56:38 PM11/12/09
to Thinking Sphinx
As expected they are 3313 and 70.32.120.23.

Stan

On Nov 12, 5:21 pm, Pat Allan <p...@freelancing-gods.com> wrote:

stasch

unread,
Nov 13, 2009, 12:55:43 AM11/13/09
to Thinking Sphinx
Problem solved! In the midst of solving my original problem I
accidentally reverted my controller. Since I was replacing the
ultrasphinx plugin with the thinking-sphinx plugin I inadvertently
restored the Ultrasphinx call! Ultrasphinx was picking up the right
address and port but obviously wasn't processing it correctly. Once I
updated the controller and performed the search with the thinking-
sphinx call it worked perfectly. And very quickly I might add.

Sorry for wasting your time.

Stan

Pat Allan

unread,
Nov 13, 2009, 1:05:48 AM11/13/09
to thinkin...@googlegroups.com
No worries, good to know it's all figured out :)

--
Pat
Reply all
Reply to author
Forward
0 new messages