Connection Issue while using Jasmine Javascript Testing Framework
I am ha开发者_开发知识库ving an issue using Jasmine on Ubuntu when trying to run the example javascript specs through Selenium using the "rake jasmine:ci" command. I will periodically get a "Connection refused" error when net/http is trying to connect to the port where Selenium is running. An example the start of the backtrace I get is:
Waiting for jasmine server on 44210...
jasmine server started.
Running: java -jar "/home/pete/.rvm/gems/ree-head/gems/selenium-rc-2.2.4/vendor/selenium-server.jar" -port 42168 > /dev/null
==> Waiting for Selenium RC server on port 42168... Ready!
/home/pete/.rvm/rubies/ree-head/lib/ruby/1.8/net/http.rb:560:in `initialize': Connection refused - connect(2) (Errno::ECONNREFUSED)
from /home/pete/.rvm/rubies/ree-head/lib/ruby/1.8/net/http.rb:560:in `open'
from /home/pete/.rvm/rubies/ree-head/lib/ruby/1.8/net/http.rb:560:in `connect'
from /home/pete/.rvm/rubies/ree-head/lib/ruby/1.8/timeout.rb:53:in `timeout'
from /home/pete/.rvm/rubies/ree-head/lib/ruby/1.8/timeout.rb:93:in `timeout'
from /home/pete/.rvm/rubies/ree-head/lib/ruby/1.8/net/http.rb:560:in `connect'
from /home/pete/.rvm/rubies/ree-head/lib/ruby/1.8/net/http.rb:553:in `do_start'
I've tried using Jasmine on Windows and it doesn't seem to have this issue. Like I said, this doesn't happen every time I try to run it (it chooses a different port each time), but it does happen a lot. I'm a little hazy as to exactly why Jasmine will occasionally find ports which are open but which it is unable to connect to. Is there something I can do on my end as far as configuration goes to solve or work around the issue? Or is this a problem in Jasmine?
Any help or ideas would be appreciated.
I solved this by running selenium outside of jasmine. Which was probably a better solution anyway. See the jasmine google group for my post.
It might be that the TCP connection came from a pool and had been idle long enough to also be disconnected. If the server didn't have a chance to explicitly close the connection, the client won't know the connection is dead until after trying + waiting. A workaround to that is using Connection:closed HTTP header.
精彩评论