Вопрос

I'm opening an HttpUrlConnection and am setting the connection timeout using its inherited setConnectTimeout method, but for one particular URL I'm getting a gateway timeout (a 504). I don't mind getting a gateway timeout as such, but I do object to it taking far longer than the connection timeout that I've set!

Does setConnectTimeout have no impact upon the gateway timeout? I couldn't see another intuitively-named method that I could use.

Thanks in advance.

Это было полезно?

Решение

You should set read timeout by setReadTimeout. If you got a 504, it means that the connection is ok, but waiting too long to read something from it.

See more here: http://docs.oracle.com/javase/6/docs/api/java/net/URLConnection.html#setReadTimeout(int)

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top