I have set responseTimeout and soTimeout to 15000ms but I still get a timeout after 90000ms.
I tested this on v1.3.18 and v1.3.17.
When I don't register jcifs my default timeout for HttpURLConnection occurs correctly after 15000ms :
connection.setReadTimeout(15000);
connection.setConnectTimeout(15000);
But when I register jcifs then the timout occurs after 90000ms:
System.setProperty("jcifs.smb.client.responseTimeout", "15000");
System.setProperty("jcifs.smb.client.soTimeout", "15000");
jcifs.Config.registerSmbURLHandler();
[...]
connection.setReadTimeout(15000);
connection.setConnectTimeout(15000);
It seems that the jcifs timeout and my default timeout are both ignored for another value.
I have also tried setProperty directly on Config but it does not change :
jcifs.Config.setProperty("jcifs.smb.client.responseTimeout", "15000");
jcifs.Config.setProperty("jcifs.smb.client.soTimeout", "15000");
(This message was posted to jcifs forum at http://thread.gmane.org/gmane.network.samba.java/9554)
For me the problem is that jcifs wraps a new HttpURLConnection so it loses every settings defined on the original connection, like the timeout settings. To prove this either I use reflection or I modify the library and change jcifs internal connection, then the timeout works fine.
(For information setting jcifs.smb.client.responseTimeout and jcifs.smb.client.soTimeout does not work)
First, I validate that jcifs is the problem : my timeout of 15000ms does not work at all when I use jcifs.Config.registerSmbURLHandler(), connection breaks after 30000ms. My 15000ms timeout works only if I remove the call to registerSmbURLHandler().
Regarding the problem, I open a connection (with jcifs previously registered) :
Then the URLStreamHandler creates a wrapping NtlmHttpURLConnection and hides the real HttpURLConnection :
So my timeout settings are applied to the wrapper NtlmHttpURLConnection, it's not applied to the true opened URLConnection. So my timeout are useless :
There are two solutions I can use to change the timeout on the wrapped connection : with reflection or with a fixed library.
With reflection, I access the private wrapped connection and change the private fields connectTimeout and readTimeout :
Or I modify the jcifs library and the constructor NtlmHttpURLConnection() :