java.net.SocketTimeoutException: Read timed out
We have developed solutions that needs to send pictures to a servlet.
Everything is 'by the book'. Emulators and other brands of mobile devices works like a charm, but when we try with i880 we get this time out exception.
The data comes partially to servlet and timeout.
Any tip about it? Some known limitation in nextel network with some workaround?
Somebody please help us.
Thanks in advance
Se the code at the bottom.
------ Portuguese Version ---------
Desenvolvemos algumas soluções móveis que precisam enviar fotos tiradas no celular.
Tudo funciona muito bem em emuladores e outras marcas de dispositivos e operadoras, mas no i880 ao tentar enviar a foto acontece essa excessão na servlet.
É como se o stream ficasse bloqueado, e chega apenas pequena parte dos dados (quando chega).
Alguma ideia/dica? Sabem de alguma limitação na rede nextel e alternativa para solução?
------ Code ----
Abaixo está o código.
here is the code that sends data in multipart format:
HttpConnection hc = null;
InputStream is = null;
ByteArrayOutputStream bos = new ByteArrayOutputStream();
byte[] res = null;
try {
hc = (HttpConnection) Connector.open(url);
hc.setRequestProperty("Content-Type", "multipart/form-data; boundary=" + getBoundaryString());
hc.setRequestMethod(HttpConnection.POST);
OutputStream dout = hc.openOutputStream();
dout.write(postBytes);
dout.close();
int ch;
is = hc.openInputStream();
while ((ch = is.read()) != -1) {
bos.write(ch);
}
res = bos.toByteArray();
if(hc.getResponseCode() != hc.HTTP_OK)
throw new Exception(new String(res));
} finally {
try {
if (bos != null) {
bos.close();
}
if (is != null) {
is.close();
}
if (hc != null) {
hc.close();
}
} catch (Exception e2) {
e2.printStackTrace();
}
}
return res;
}
- Logue-se ou registre-se para enviar comentários
- 3288 leituras
