Hello all - hoping one of you have seen this...
In a nutshell, reading from an HttpConnection's InputStream doesn't read all the data. read() returns -1 somewhere between 3K to 5K (it's random and never the same place) into an 8-10K http page, causing my app to fail. I'm not doing anything unusual - just the standard:
while ((ch = is.read()) != -1) {
strBuff.append((char) ch);
}
The http response is chunked, so the contentlength isn't available, that's why I'm doing this type read. If the HTTP response is less than 3K bytes I can receive it fully and my app works fine. The built-in browser on the device can retrieve the same exact URL (all 8-10K of it) from the exact same location.
This is running in its own thread, too. The only potential problem I can see is that I have a TimerTask kicking off every 2 minutes using a different HTTP thread to open an HTTP URL (it sends an update to a web service). I don't think the two threads are conflicting... only one of them is running at a time. How many concurrent HttpConnections does the RIM7520 support? I thought it was 4. I'm not getting any exceptions that it cannot open any more HttpConnections, so I have to assume this isn't a problem.
The thing that's really messing with my head is that this works PERFECTLY in the simulator!!! What's different between the simulator and the device in this regard? Just the Nextel network, right? Am I hitting some timeout? I'm not getting an InterruptedIOException (I'm asking for them when I open the HttpConnection). Here's how I get an HttpConnection:
httpConnection = (HttpConnection) Connector.open(m_sURL,
Connector.READ_WRITE, true);
ANY ideas would be MOST gratefully accepted - this is driving me insane!
Thanks,
Bret