# Slow/unpredictive response of post\_form from rails lib

**URL:** <https://www.ruby-forum.com/t/slow-unpredictive-response-of-post-form-from-rails-lib/169613>\
**Category:** Rails\
**Created:** [June 5, 2009, 10:43pm UTC](https://www.ruby-forum.com/t/slow-unpredictive-response-of-post-form-from-rails-lib/169613 "2009-06-05T22:43:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![makuchaku](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/d9b06d/32.png) [@makuchaku](https://www.ruby-forum.com/u/makuchaku)\
**Post date:** [June 5, 2009, 10:43pm UTC](https://www.ruby-forum.com/t/slow-unpredictive-response-of-post-form-from-rails-lib/169613/1 "2009-06-05T22:43:08Z")

</div>

Hi friends,

I’m facing a very strange problem…

I consume a webservice from within my rails app. I’ve written a thin  
wrapper around the webservice using Net::HTTP.post\_form

However, when calling the API from within my controllers, the API calls  
randomly fail, complaining about timeout.

But - when I wrote a simple iterative test (500 iterations), calling the  
same webservice using same thin wrapper (via rake) - to my surprise,  
none of the calls failed.

I repeated the iterative test twice before thinking of writing to Rails  
forum…

Any suggestions on what I might be doing wrong?

Thanks in advance…

Regards,  
Maku

---

<div class="post-metadata">

**Author:** ![makuchaku](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/d9b06d/32.png) [@makuchaku](https://www.ruby-forum.com/u/makuchaku)\
**Post date:** [June 5, 2009, 10:47pm UTC](https://www.ruby-forum.com/t/slow-unpredictive-response-of-post-form-from-rails-lib/169613/2 "2009-06-05T22:47:43Z")

</div>

A timeout from time to time isn’t something to worry about, in your  
library you can just add a “retry” clause and retry a specific number  
of times (maybe 2) before raising the exception to the calling code.

- 

Maurício Linhares  
[http://alinhavado.wordpress.com/](http://alinhavado.wordpress.com/) (pt-br) |  
[http://codeshooter.wordpress.com/](http://codeshooter.wordpress.com/) (en)

On Fri, Jun 5, 2009 at 5:43 PM, Mayank
