Nokia N97電話からサーバーにファイルをアップロードしました。すべて正常に動作しますが、ファイルをアップロードした後、サーバーから応答を取得したいと思います。問題は、30分以上経っても応答がないことです。httpConnection.getResponseCode()のコードブロックが応答を待っているのがわかります。Sony Ericssonでテストしたところ、応答が非常に速いので、NokiaN97の問題だと思います。(他の電話でも正常に動作するため、サーバーの問題ではありません)
なぜこのことがノキアでのみ起こるのか誰かが知っていますか?
コードスニペットは次のとおりです。
public uploadFile(){
httpConn = (HttpsConnection) Connector.open(url, Connector.READ_WRITE);
...
//set httpConn parameters and request method
...
writeParametersAndFileName(os, "text/plain");
**writeFileToStream(os);**
os.write("\r\n".getBytes());
os.write("--".getBytes());
os.write(boundary.getBytes());
os.write("--".getBytes());
os.write("\r\n".getBytes());
*//here code blocks on Nokia N97. Same thing happens if I use os.flush() after
// I send chunks of the file*
.....
codeResp = httpConn.getResponseCode();
// check condition
checkResponseHeader();
}
public writeFileToStream() {
InputStream is = null;
FileConnection c = null;
try
{
c = (FileConnection) Connector.open("file:///"+ sourcePath, Connector.READ);
if(c.exists()) {
is = c.openInputStream();
long fs = c.fileSize();
while (total < fs) {
byte[] data = new byte[512];
int readAmount = is.read(data,0,512);
total += readAmount;
os.write(data, 0, readAmount);
}
//os.flush();
}
catch (IOException ex) {
//
}
finally
{
//close connection
}
}