lundi 3 juin 2019

How to set default global Java Socket Timeout as Java arguments in my web service client application (Not to set Read Timeout)?

I have a SOAP web service client application(Scala) which uses the generated client stubs by Java wsimport -verbose -Xnocompile command.

In the existing application, the http timeouts are set by using external Java arguments in the build.sbt file like below.

bashScriptExtraDefines += "addJava \"-Dsun.net.client.defaultReadTimeout=300000\"\n"

bashScriptExtraDefines += "addJava \"-Dsun.net.client.defaultConnectTimeout=300000\"\n"

Here only the default Timeout values are provided for only ReadTimeout and ConnectTimeout. Now I need a way to specifically set the SO timeout like above. When I search through the stack overflow answers I could only find answers about setting only read timeout and connection timeout, not the Socket Timeout. https://docs.oracle.com/javase/8/docs/technotes/guides/net/properties.html

In the Java 8 docs also it mentioned about readtimeout and connection timeout, not about so timeout.

sun.net.client.defaultConnectTimeout (default: -1) sun.net.client.defaultReadTimeout (default: -1) These properties specify the default connect and read timeout (resp.) for the protocol handler used by java.net.URLConnection. sun.net.client.defaultConnectTimeout specifies the timeout (in milliseconds) to establish the connection to the host. For example for http connections it is the timeout when establishing the connection to the http server. For ftp connection it is the timeout when establishing the connection to ftp servers.

Is there anyway we could set SO timeout specifically with the Java arguments in build.sbt?




Aucun commentaire:

Enregistrer un commentaire