Connection exception

  • Replies:0
Roberto Gilli
  • Forum posts: 2

Sep 4, 2017, 6:09:20 PM via Website

Hi,
i have a problem.
My app exery 20 seconds send datas to a server.
The problem is that after few minutes i receive connection timeout exception and isn't a time problem.
code:
URL webServiceURL = new URL(webServiceURLString);
wcfConnection = (HttpURLConnection) webServiceURL.openConnection();
wcfConnection.setConnectTimeout(UtilityClass.connectTimeout); // set timeout to 30 seconds
wcfConnection.setReadTimeout(UtilityClass.readTimeout);
wcfConnection.setRequestProperty("Accept-Charset", charset);
wcfConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded;charset=" + charset);
wcfConnection.setDoOutput(true); // This triggers
wcfConnection.setDoInput(true);
OutputStream out = wcfConnection.getOutputStream();

The last instruction rise the exception.

All run right for few minutes and then rise the exception always.
On a Android 6 Samsung S5 the problem not occours.
On a Android 7 Huawei P9 lite the problem occours.

Thanks
Roberto Gilli

Reply