I have a servlet, which responds in XML format.
Clients conntect to this servlet via httpsURLConnection.
Now is it a problem if clients do not call connection.disconnect()
?
lets follow this scenario:
url = "https://abc.com/ws/servlet?task=login"
openconnection()...
now the client have to post username and password, if success, he can post new parameters like task=getSomeData,...etc
. before disconnect.
for every Connection, the client becomes new httpsession.
if the client does not call connection.dissconnect(), would the connection be closed automatically after session timeout? if not, then when? how long would it be alive? is it a problem for the server if there are sooomany "UNdisconnected" connections?
UPDATE: Sample Client
HttpsURLConnection conn = null;
InputStream inputstream = null;
try{
URL url = new URL("https://abc.com/ws/servlet");
SSLSocketFactory sslsocketfactory = (SSLSocketFactory) SSLSocketFactory.getDefault();
conn = (HttpsURLConnection)url.openConnection();
conn.setSSLSocketFactory(sslsocketfactory);
inputstream = conn.getInputStream();
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document doc = db.parse(inputstream);
......;
}catch(Exception ex){
ex.printStackTrace();
}
finally{
try {
if( inputstream != null )
inputstream.close();
if( conn != null )
//conn.disconnect();
} catch (Exception e) {
e.printStackTrace();
}
}
Client sets no timeout, in this case, which timeout would be used in the server if this client doesn't call disconnect()? Servlet Container Connector timeout? but changing this will affect all Applications within this container.
the default Tomcat Connector timeout is 20000 = 2 min, should that mean, i can only use my opened Connection in max 2 min? after 2 min will auto disconnected?
many Thanks.