0

My script works but due to some reason it is throwing Net::ReadTimeout error. I presume due to high number of connections to the API. Any way to delay timeout using Savon? Thanks.

wsdl = 'https://org.my.domain/webservices/myservice.asmx?WSDL'

# Open Client Webservice
client = Savon.client(wsdl: wsdl, ssl_verify_mode: :none, ssl_version: :TLSv1, convert_request_keys_to: :none)

# Connect to Webservice - Authenticate
response = client.call(:authenticate, message: { username: 'user', password: 'pwd', organization: 'org', domain: 'my.domain' })
emyatsuna
  • 41
  • 7
  • 1
    searching before asking always helps: https://stackoverflow.com/questions/6384230/how-to-set-savon-default-timeout-value :-) – Steffen Roller Jul 15 '20 at 00:33
  • thanks! I ended up increasing the timeout like @benjessop suggested. It's causing really slow response but not the `Net::ReadTimeout`. – emyatsuna Aug 08 '20 at 15:03

1 Answers1

2

You will want to increase the read timeout if you cannot decrease the amount of calls you are making to the API. In reality, your programs should always be respectful to the resource they are interacting with and should allow for other programs to access them without detracting from performance.

If you did want to increase the read timeout, the syntax would depend what version you are using, for version 2.x:

client = Savon.client(
    wsdl: wsdl,
    ssl_verify_mode: :none,
    ssl_version: :TLSv1,
    convert_request_keys_to: :none,
    open_timeout: 400,
    read_timeout: 400,
)

For version 3.x:

client.http.send_timeout = 400
client.http.receive_timeout = 400

Be wary these are seconds.

benjessop
  • 1,729
  • 1
  • 8
  • 14
  • hi, thanks @benjessop! Yes, you are correct. It's taking an indefinite number of calls (same time). Adjusting timeout is good and may stop getting NET::ReadTimeout error but will have slow responses. I think it's because it's reading the whole WSDL. Would you know if there's a way to count or display the total timeouts? – emyatsuna Jul 16 '20 at 04:31