I am using savon to make some api calls but its taking long time to respond because of that i am getting time out errors.so is there any way to change the default value of timeout. I am using savon 0.7.9 ruby 1.8.7 and rails -v 2.3.2.
Asked
Active
Viewed 8,787 times
2 Answers
24
Savon uses the gem HTTPI as interface to the transport layer. Therefore you need to change the timeout for the http calls.
here an example (Savon 1.x)
jira = Savon::Client.new do
wsdl.document = 'http://jira.my-domain.com/rpc/soap/jirasoapservice-v2?wsdl'
end
jira.http.read_timeout = 300
EDIT: the syntax has changed for Savon 2.x
jira = Savon.client(
wsdl: 'http://jira.my-domain.com/rpc/soap/jirasoapservice-v2?wsdl',
open_timeout: 300,
read_timeout: 300,
ssl_verify_mode: :none)
p jira.operations

Steffen Roller
- 3,464
- 25
- 43
-
3If you put `http.read_timeout = 300` inside the block it will not work. – Pikachu May 23 '12 at 19:14
-
7Those are seconds by the way. – Jong Bor Lee Jun 12 '12 at 22:35
2
In Savon 3, the operation is as follows:
client = Savon.new(wsdl_url)
client.http.send_timeout = 300
client.http.receive_timeout = 300
In Savon 3, you can't pass these in as options to the constructor, but you can supply a custom http adapter (to replace the default Savon::HTTPClient) as follows:
client = Savon.new(wsdl_url, MyAdapter.new)

JellicleCat
- 28,480
- 24
- 109
- 162
-
1Savon really like changing how they do things... Thanks for the update. – alex_milhouse Nov 16 '16 at 21:52