getRequestCode on nokia J2ME

370 Views Asked by At

I have strange problem with nokia phone. I'm developing J2ME midlet and trying to run it on nokia (n73). This midlet makes httpRequest. First, second and several more reqeust makes good. But after that next request fails with IOException.

There are no such problems in WTK emulator.

try{ hcon = (HttpConnection) Connector.open(url);
     if (hcon.getResponseCode() == HttpConnection.HTTP_OK)
        res = hcon.openInputStream();
} catch (IOException e)
{
    ...

There is stack trace:

- com.symbian.midp.io.protocol.http.HttpConnectionNative.throwIOException(), bci=5 
- com.symbian.midp.io.protocol.http.HttpConnectionNative.waitForTransaction(), bci=33 
- com.symbian.midp.io.protocol.http.HttpConnectionNative.sendRequest(), bci=309 
- com.symbian.midp.io.protocol.http.HttpConnectionNative.ensureResponse(), bci=37 
- com.symbian.midp.io.protocol.http.HttpConnectionNative.openDataInputStream(), bci=29 
- com.symbian.midp.io.protocol.http.HttpConnectionNative.openInputStream(), bci=1 
- ru.megafon.sgc.Main.sendHttpGet(), bci=48 
- ru.megafon.sgc.Main$2.run(), bci=115 
- java.lang.Thread.run(), bci=11
1

There are 1 best solutions below

1
On

You're probably not closing the stream AND the HttpConnection object. You must close both, otherwise you'll have problems like what you're seeing -- you can only have one or two connections open at a time in general on these devices.