I developed a menu application for Android , the waiter by the app sees all the tables, by the application opens the table, makes the request that goes out in the kitchen and so on.
The web service returns a JSON for each request and makes the transactions in the database, even running on a tomcat .
The application after a certain time of use can no longer connect to the server, after testing I saw that I get a java.net.SocketTimeoutException
.
private static String sCookie;
public static String acessar(String url){
HttpURLConnection conn = null;
String conteudo = "";
try {
conn = (HttpURLConnection) ((new URL(url).openConnection()));
conn.setConnectTimeout(5000);
conn.setReadTimeout(5000);
conn.setRequestProperty("Connection","Close");
if(sCookie != null && !"".equals(sCookie))
conn.setRequestProperty("Cookie", sCookie);
int responseCode = conn.getResponseCode();
if(responseCode == 200) {
conteudo = streamToStr(conn.getInputStream());
String cookie = conn.getHeaderField("set-cookie");
if(cookie != null && cookie.length() > 0)
sCookie = cookie;
}
return conteudo;
}
catch(Exception ex){
ex.printStackTrace();
} finally {
if(conn != null)
conn.disconnect();
}
return conteudo;
}
I thought it was tomcat , I changed the default settings for Connector
, but it did not work.
<Connector port="9090"
enableLookups="false"
protocol = "HTTP/1.1"
acceptorThreadCount="2"
maxThreads="300"
connectionTimeout="30000"
compressableMimeTypes="text/*,application/x-javascript,application/javascript"
compressionMinSise="2048"
noCompressionUserAgents="gozilla, traviata"
maxSpareThreads="150"
maxRequestsPerChild="20000"
compression="force"
redirectPort="8443"
keepAlive="true"
keepAliveTimeOut="20000">
</Connector>
Thanks in advance for any help in trying to figure out what might be causing this problem.