Forum: Ruby on Rails open call works fine in irb but not through webrick server

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
A5f392649150a91108cf95c34d8bb0d4?d=identicon&s=25 Karika (Guest)
on 2009-05-06 20:50
(Received via mailing list)
require 'rss/1.0'
require 'rss/2.0'
require 'open-uri'

source = "something.com" # url or local file
content = "" # raw content of url will be loaded here
open(source,:proxy => nil) do |s| content = s.read end
rss = RSS::Parser.parse(content, false)

puts "Root values"
print "RSS title: ", rss.channel.title, "\n"
##############################################
Now, running this code through IRB works fine and gives me correct
result.
Whereas, If I run same piece of code through WEBRICK server, it gives
me following error ...

------------------------------------------------------------------------------------------------------------------
OpenSSL::SSL::SSLError in Document#feed
SSL_CTX_new:: library has no ciphers
RAILS_ROOT: ./script/../config/..

Application Trace | Framework Trace | Full Trace
D:/ruby/lib/ruby/site_ruby/1.8/net/protocols.rb:38:in `new'
D:/ruby/lib/ruby/site_ruby/1.8/net/protocols.rb:38:in `initialize'
D:/ruby/lib/ruby/1.8/net/http.rb:430:in `open'
D:/ruby/lib/ruby/1.8/net/http.rb:430:in `do_start'
D:/ruby/lib/ruby/1.8/net/http.rb:419:in `start'
D:/ruby/lib/ruby/1.8/net/http.rb:821:in `request'
D:/ruby/lib/ruby/1.8/net/http.rb:615:in `get'
------------------------------------------------------------------------------------------------------------------

Any clue ??
Is it something to do with SSL certification ?

Thanks,
Karika Shah
1e7782e67bb34c9c67ed19d5cde5f4eb?d=identicon&s=25 Tom Z Meinlschmidt (Guest)
on 2009-05-07 01:51
(Received via mailing list)
irb != rails

so try this script via script/console

irb is interactive ruby console, so libraries etc could be different for
ruby and for rails

if this will work in script/console, then it will work via
mongrel/webrick as well

tm

Karika wrote:
> print "RSS title: ", rss.channel.title, "\n"
>
> Any clue ??
> Is it something to do with SSL certification ?
>
> Thanks,
> Karika Shah
>

--
===============================================================================
Tomas Meinlschmidt, MS {MCT, MCP+I, MCSE, AER}, NetApp Filer/NetCache

www.meinlschmidt.com  www.maxwellrender.cz  www.lightgems.cz
===============================================================================
A5f392649150a91108cf95c34d8bb0d4?d=identicon&s=25 Karika (Guest)
on 2009-05-07 17:57
(Received via mailing list)
I tried using script/console
It still give me same error ...

---------------------------------------------------------------------------------------------------------------------------------

D:\Ruby Applications\website>ruby script\console
Loading development environment.
>> require 'open-uri'
=> true
>> source = "http://google.com"
=> "http://google.com"
>> open(source)
OpenSSL::SSL::SSLError: SSL_CTX_new:: library has no ciphers
        from D:/ruby/lib/ruby/site_ruby/1.8/net/protocols.rb:38:in
`new'
        from D:/ruby/lib/ruby/site_ruby/1.8/net/protocols.rb:38:in
`initialize'
        from D:/ruby/lib/ruby/1.8/net/http.rb:430:in `open'
        from D:/ruby/lib/ruby/1.8/net/http.rb:430:in `do_start'
        from D:/ruby/lib/ruby/1.8/net/http.rb:419:in `start'
        from D:/ruby/lib/ruby/1.8/net/http.rb:324:in `start'
        from D:/ruby/lib/ruby/1.8/open-uri.rb:544:in `proxy_open'
        from D:/ruby/lib/ruby/1.8/open-uri.rb:525:in `direct_open'
        from D:/ruby/lib/ruby/1.8/open-uri.rb:169:in `open_loop'
        from D:/ruby/lib/ruby/1.8/open-uri.rb:164:in `catch'
        from D:/ruby/lib/ruby/1.8/open-uri.rb:164:in `open_loop'
        from D:/ruby/lib/ruby/1.8/open-uri.rb:134:in `open_uri'
        from D:/ruby/lib/ruby/1.8/open-uri.rb:424:in `open'
        from D:/ruby/lib/ruby/1.8/open-uri.rb:85:in `open'
        from (irb):13
>>

---------------------------------------------------------------------------------------------------------------------------------
This topic is locked and can not be replied to.