SocketTimeoutException in 5 Seconds - Any Way to Increase?

The server I'm on is responding regularly for 5.5 seconds, but I get a SocketTimeout exception in 5 seconds. Is there any way to increase this value? Will upgrading to a paid level allow me this ability?

+6
source share
2 answers

See https://developers.google.com/appengine/docs/java/urlfetch/#Fetching_URLs_with_java_net

In particular,

You can set a deadline for the request, the most time the service will wait for a response. The default deadline for sampling is 5 seconds. The maximum time limit is 60 seconds for HTTP requests and 10 minutes for task queue requests and cron job requests. When using the URLConnection Interface, the service uses the connection timeout (setConnectTimeout ()) plus the read timeout (setReadTimeout ()) as the time limit.

+4
source

You did not mark your question in any language, so I will try to cover those that I know.

I did not test any of them in production, only during development.

Python

It seems to support the setdefaulttimeout method. You can pass the number of seconds as a float or int :

 import socket socket.setdefaulttimeout(10) # create socket connections as usual… 

Java

The socket documentation claims to support java.net.Socket . According to this answer, you can specify a timeout in milliseconds , like this (10 seconds):

 Socket socket = new Socket(); socket.connect(new InetSocketAddress(ipAddress, port), 10000); 

Go

Using socket.DialTimeout instead of socket.Dial you can specify a timeout as time.Duration (i.e. nanoseconds ).

 import ( // … "appengine/socket" ) func handler(w http.ResponseWriter, r *http.Request) { c := appengine.NewContext(r) conn, err := socket.DialTimeout(c, "tcp", "myhost.com:1234", 10*time.Second) // … } 

Note that a timeout may include name resolution if you are connecting to a host name and not to an IP voice. There may also be an upper limit that is language independent, but not documented.

+1
source

Source: https://habr.com/ru/post/971425/


All Articles