08-27-2012 08:49 AM
Hi,
I'm developing BB application, which fetches data from my server. Few days ago one of my users reported an error and in logs I've seen, that response for one of the requests was cut after 12k of chars. There were more reports from that user with responses cut - usually it's after 12k chars, but sometimes it's 8 or 4k. Error is non deterministic - occurs on different addresses and not always (some bigger than 12k chars responses were received correctly).
Yesterday second user reported same error. Application was released more than half year ago and to this moment such problems didn't happen. There are no changes in communication on app nor server side since beginning.
Both users are using BB9900 and errors happened when they were using wifi connection.
Have someone faced similar problems? What can causes such issue?
08-27-2012 09:01 AM
Can you confirm that the code is a a loop reading till EOF, or are you using IOUtilities.streamToBytes(...);
Does the problem occur with the number of bytes you receive, or when you convert the bytes to a String?
08-27-2012 09:20 AM
I'm using IOUtilities.streamToBytes(...)
Length is measured on String after converting. Unfortunately I'm not logging bytes size and I'm unable to reproduce issue on my devices to determine when content is cut off.
08-27-2012 09:49 AM
OK, while it might be useful to know the bytes length, I'm not sure that is relevant.
Trouble is, I've no real idea what is relevant in this case. Never seen a similar problem over WiFi. Usually things work properly on WiFi and people have problems on other connection types.
Grasping at straws here, I wonder of there is somethin in the encoding. How do you convert the bytes to String? Using "UTF-8"?
08-27-2012 10:23 AM
I'll add such information to logs in new release, but for now there aren't release plan very soon. Yes, I'm making String with "UTF-8" parameter. All code responsible for receiving String from connection stream looks that:
InputStream inputStream = connection.openInputStream();
byte[] bytes = IOUtilities.streamToBytes(inputStream);
inputStream.close();
int code = connection.getResponseCode();
if ( code != 200 ) {
log.warn("Possible connection issue, response code: " + code);
}
connection.close();
String responseString = new String(bytes, "UTF-8");Yeah, wifi thing and this, that problem occurs for only 2 user with BB9900 is really weird. I've no idea what's wrong:/
08-28-2012 02:23 AM
08-28-2012 05:17 AM - edited 08-28-2012 05:18 AM
I would be cautious regarding using the code supplied by Kiran_Snist because it converts the bytes to characters using UTF-8, for each of the 256 byte segments. If a double (or longer) byte UTF-8 character spans the 256 byte segment, I suspect it will not get converted correctly so this could corrupt the data.