I''ve been struggling with an issue with ActiveResource for a bit now:
when a hostname resolves for an ActiveResource request, but there''s no
server on the other end to return information, ActiveResource''s timeout
value doesn''t work. The request just hangs.
After reviewing the ActiveResource code, I''ve realized that this is
because the underlying Net:Http object only has one timeout value set:
read_timeout. The Net:Http library defines this as "Seconds to wait
until reading one block (by one read(2) call)". The Net:Http lib also
defines another timeout value, open_timeout, which is defined as
"Seconds to wait until connection is opened".
I''m unsure why open_timeout isn''t set by default with the
timeout value
set on an ActiveResource class, but after modifying the
ActiveResource::Connection class to include the open_timeout on the http
objects, my issue was resolved!
I''m new to rails so I''m unsure of the best way to actually
make this
modification in my project; I don''t want to just change the code in my
gem directory. Is there a proper way to make these modifications in a
rails project? I''ve seen that it''s possible to load rails
classes from
the /vendor folder, but do they all have to be there for it to work? I
started to make subclasses of the ActiveResource::Base and
ActiveResource::Connection classes, but it seemed like maybe there was
an easier way to do this, as the function that creates the Net:Http
instance is private...any thoughts?
--
Posted via http://www.ruby-forum.com/.