3

Running into the following exception while trying to query a RESTful api(note not my api, so going in and doing anything with the actual server is unfortunately not possible): javax.naming.NamingException: LDAP response read timed out.

I am using Python-requests to handle all of my GETs, POSTs, etc, and the actual connection appears to always be fine, but when the server is under heavy load it appears to not actually return all of the data before the read timesout. Anybody know of anyway to change the timeout on the read? Looking through the Python-requests documentation, I was only able to find information on changing the connection timeout.

Note, I have read through other read timeout questions, but all were questions regarding Pythons other http/url libraries.

Brent Hronik
  • 2,357
  • 1
  • 27
  • 43
  • 4
    That is as *server side* timeout. Adjusting the timeout for requests won't fix that. – Martijn Pieters Apr 15 '13 at 17:36
  • "*it appears to not actually return all of the data before the read timesout*" What do you directly observe that leads you to this conclusion? – Robᵩ Apr 15 '13 at 17:39
  • I agree with @MartijnPieters. It rather sounds like the service is getting the exception from LDAP, and forwards it on to the client. – eandersson Apr 15 '13 at 17:40
  • @Robᵩ, The only thing I observe that would leave me to believe that was that read timeout. Since it is the Python client that was doing the reading, I assumed it was client-side. – Brent Hronik Apr 15 '13 at 17:42
  • @Martijn Pieters, thanks for pointing that out, I will contact the server-admins to see if they can provide support. – Brent Hronik Apr 15 '13 at 17:44
  • 1
    You might like to have a look at my answer to a similar question: http://stackoverflow.com/a/22377499/1653521 – Hieu Mar 13 '14 at 11:47

2 Answers2

2

Maybe you can set timeout parameter as a tuple, just like

r = requests.get('https://github.com', timeout=(3.05, 27))

The first value of tuple is connection timeout(3.05), the second is read timeout(27)

more details in requests doc: https://requests.readthedocs.io/en/master/user/advanced/#timeouts

smart123s
  • 17
  • 1
  • 7
Rhys Pang
  • 213
  • 3
  • 10
-3

If you don't set timeouts explicitly your OS will take care of them. Changing global system timeouts are OS-dependant then. Under Linux you can change /proc/sys/net/ipv4/tcp_syn_retries (http://www.sekuda.com/overriding_the_default_linux_kernel_20_second_tcp_socket_connect_timeout).

Dariusz Cieslak
  • 306
  • 3
  • 3
  • No, this is incorrect. It is clearly stated in the documentation that "If no timeout is specified explicitly, requests do not time out." https://requests.readthedocs.io/en/master/user/quickstart/#timeouts – lindhe May 31 '20 at 17:58