I am writing a script to download webpages from a favourite radio program
in order to grab the URLs ot MP3s of recent shows that I want to then pass
on to XMMS to play. I am able to get the pages, but often I get an error
that the connection has been reset by the peer, specifically:
/usr/lib/ruby/1.6/net/protocol.rb:582:in `sysread': Connection reset by
peer (Errno::ECONNRESET)
from /usr/lib/ruby/1.6/net/protocol.rb:582:in `fill_rbuf' from
/usr/lib/ruby/1.6/net/protocol.rb:527:in `readuntil' from
/usr/lib/ruby/1.6/net/protocol.rb:537:in `readline' from
/usr/lib/ruby/1.6/net/http.rb:800:in `get_reply' from
/usr/lib/ruby/1.6/net/http.rb:675:in `get_response' from
/usr/lib/ruby/1.6/net/http.rb:579:in `header' from
/usr/lib/ruby/1.6/net/http.rb:590:in `body' from
/usr/lib/ruby/1.6/net/http.rb:314:in `get' from
/usr/lib/ruby/1.6/net/http.rb:314:in `call' from
/usr/lib/ruby/1.6/net/http.rb:427:in `receive' from
/usr/lib/ruby/1.6/net/http.rb:322:in `get2' from
/usr/lib/ruby/1.6/net/http.rb:320:in `connecting' from
/usr/lib/ruby/1.6/net/http.rb:320:in `get2' from
/usr/lib/ruby/1.6/net/http.rb:314:in `get' from ./testhttp.rb:34:in
`get_shows_data' from ./testhttp.rb:85
I wrote a class to encapsulate the logic of this script. I have an
instance variable to take care of the connection to the host. In methods
that use this variable.
Specifically, the code is:
@h = Net::HTTP.new('radio.cbc.ca')
I call resp, data = @h.get('/programs/quirks/archives.htm', nil)
to get the data for that connection. I have tried calling the finish
method on the connection after this to end the connection session. This
does not help What are the proper steps to initiate a connection, grab a
web page's data, then disconnect? Any help would be GREATLY appreciated.