Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Contributor
jaywhy13
Posts: 31
Registered: ‎11-14-2012
My Device: Blackberry 9780

TCP/WAP on EDGE extremely SLOW

Hi I'm a newbie... first time building an app with any real network connectivity and I'm seeing some terrible response times for content. I'm not sure if it's the networks out here or if that's just EDGE in general. It takes any where between 0.7-10 seconds to download a 3KB text file from the Internet. I'm at a loss at to where to start in terms of optimization. I figure on the server side I can do caching to ensure that as little processing as possible is happening on the server but what can I do on the client side? Compression? BIS? Any suggestions?

Please use plain text.
Developer
simon_hain
Posts: 16,136
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: TCP/WAP on EDGE extremely SLOW

welcome to the support forums.
yes, edge can be slow.

if you need only small data you could use push, would be more efficient on top, but only feasible if you control both server and client side.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
Contributor
jaywhy13
Posts: 31
Registered: ‎11-14-2012
My Device: Blackberry 9780

Re: TCP/WAP on EDGE extremely SLOW

By PUSH do you mean Blackberry BIS? Is there a cost for this? Also, when you say control over client and server do you mean the phone and the server it's communicating with? We're building the app and we're writing the server side application. In that scenario, we have full control there... what options do we have there?

Please use plain text.
Developer
simon_hain
Posts: 16,136
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: TCP/WAP on EDGE extremely SLOW

push would mean bis-push, yes. the server would send the data to the client without the client actively pulling, its more efficient and saves a lot of battery, as receiving is about the factor 100 cheaper (in terms of battery) than sending.

if you are set on the pulling scenario there is little you can do to influence stuff.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
Contributor
jaywhy13
Posts: 31
Registered: ‎11-14-2012
My Device: Blackberry 9780

Re: TCP/WAP on EDGE extremely SLOW

What do I need to do to use BIS? I was a bit unclear on that. Is BIS what Network Providers generally use? I read that BIS is automatic with a BES. I'm not hard and fast on "pulling", that just seemed like the logical way to do it coming from a normal web dev background. 

 

How would BIS integration typically work? Is there a cost (financial) to the developer and if so, how is that usually managed? Is that usually pushed straight to the client? I really know nothing about BIS. 

Please use plain text.
Developer
simon_hain
Posts: 16,136
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: TCP/WAP on EDGE extremely SLOW

bis push is free. using bis as a transport officially requires a certain alliance membership level, it is a bit of a grey area to use it without it, you can get access if you apply for bis push.

BES is a different thing again.
this should clear things up (and make room for a lot of new confusion):
http://supportforums.blackberry.com/t5/Java-Development/Networking-Transports-II/ta-p/446742
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
Contributor
jaywhy13
Posts: 31
Registered: ‎11-14-2012
My Device: Blackberry 9780

Re: TCP/WAP on EDGE extremely SLOW

Is this normally the scenario? I gzipped content and decompressed it on the mobile and still had to wait up to 90 seconds for less than 1KB of data. TCP did the job in 2-5 or so seconds. I'm not sure I'll have time to negotiate BIS now in this stage of development :smileysad: so I have to pull out all the big guns there are. 

Please use plain text.
Developer
peter_strange
Posts: 19,604
Registered: ‎07-14-2008
My Device: Not Specified

Re: TCP/WAP on EDGE extremely SLOW

90 seconds for 1K seems like too much, I don't think it took that long in the old 2G days before things like EDGE!

 

I think you will have to time stamp the various phases of your operation and work out which component is taking the time.  I would time stamp just before the open, just before getting the response code, just after you have downloaded the data (but before you decompress it) after you decompress it and so on.  Can you do that with some sample code and show us where all the time is taken in the code?

Please use plain text.
Contributor
jaywhy13
Posts: 31
Registered: ‎11-14-2012
My Device: Blackberry 9780

Re: TCP/WAP on EDGE extremely SLOW

Ok, here's the bulk of the code...

try {

HttpConnection httpConnection = (HttpConnection) connectionDescriptor
.getConnection();

// Set headers if GZIP is enabled...
if (useCompression) {
// httpConnection.setRequestMethod(HttpProtocolConstants.HTTP_METHOD_POST);
httpConnection.setRequestProperty(
HttpProtocolConstants.HEADER_USER_AGENT,
"Blackberry Device");
httpConnection.setRequestProperty(
"x-rim-transcode-content", "none");
httpConnection
.setRequestProperty(
HttpProtocolConstants.HEADER_CONTENT_TYPE,
HttpProtocolConstants.CONTENT_TYPE_APPLICATION_X_WWW_FORM_URLENCODED);
httpConnection.setRequestProperty(
HttpProtocolConstants.HEADER_ACCEPT_ENCODING,
"gzip");
}

// Go ahead and make the request!!!!
long startTime = System.currentTimeMillis(); // <!-- start tracking time for the request

int status = httpConnection.getResponseCode();

String contentEncoding = httpConnection.getEncoding();

long endTime = System.currentTimeMillis(); // <!-- stop tracking time for the request

if (status == HttpConnection.HTTP_UNAUTHORIZED) {
Utils.err("We cannot touch the Internet");
} else {
InputStream is = httpConnection.openInputStream();
String response;
byte[] rawData;

// Now check on the encoding...
if (contentEncoding != null
&& contentEncoding.equals("gzip")) {
// The data is compressed
long startUnzip = System.currentTimeMillis(); // <!-- start tracking time to un-gzip
GZIPInputStream gzipInputStream = new GZIPInputStream(
is);
rawData = net.rim.device.api.io.IOUtilities
.streamToBytes(gzipInputStream);
response = new String(rawData);
long endUnzip = System.currentTimeMillis(); // <!-- stop tracking time for un-gzip
Utils.log("Took us " + (endUnzip - startUnzip)
+ " ungzip response");
} else {
rawData = net.rim.device.api.io.IOUtilities
.streamToBytes(is);
response = new String(rawData);
}

// Now we have string and bytes saved
....

}
} catch (IOException ioe) {
Utils.err("Could not open a connection, IOException occurred. "
+ ioe.getMessage());
action.urlUnreachable();
}

 

 

Now I get the following output from that... Gzipping is fine, it usually takes just a couple ms. I've logged 3 requests below with the Gzip time. I logged file response size (in Bytes) and response time in ms. Notice the third request takes 38 seconds. This seems to happen every now and again. 

 

Took us 10ms ungzip response
[TCP Cellular] [722B, 439ms] 


Took us 3ms ungzip response
[TCP Cellular] [722B, 502ms] 

 

Took us 6ms ungzip response
[TCP Cellular] [730B, 582ms] 

 

Took us 8ms ungzip response
[TCP Cellular] [714B, 38019ms

 

Took us 1ms ungzip response
[TCP Cellular] [774B, 653ms] 

Please use plain text.
Developer
peter_strange
Posts: 19,604
Registered: ‎07-14-2008
My Device: Not Specified

Re: TCP/WAP on EDGE extremely SLOW

Can you extend the testing to d something like this and tell us what you see?

 

long startTime = System.currentTimeMillis();

long getCOnnectionTime, getResponseTime, getDataTime, unzipTime, responseTime;

HttpConnection httpConnection = (HttpConnection) connectionDescriptor

.getConnection();

getCOnnectionTime = System.currentTimeMillis();

// Set headers if GZIP is enabled...

if (useCompression) {

// httpConnection.setRequestMethod(HttpProtocolConstants.HTTP_METHOD_POST);

httpConnection.setRequestProperty(

HttpProtocolConstants.HEADER_USER_AGENT,

"Blackberry Device");

httpConnection.setRequestProperty(

"x-rim-transcode-content", "none");

httpConnection

.setRequestProperty(

HttpProtocolConstants.HEADER_CONTENT_TYPE,

HttpProtocolConstants.CONTENT_TYPE_APPLICATION_X_WWW_FORM_URLENCODED);

httpConnection.setRequestProperty(

HttpProtocolConstants.HEADER_ACCEPT_ENCODING,

"gzip");

}

// Go ahead and make the request!!!!

int status = httpConnection.getResponseCode();

String contentEncoding = httpConnection.getEncoding();

getResponseTime = System.currentTimeMillis();

if (status == HttpConnection.HTTP_UNAUTHORIZED) {

Utils.err("We cannot touch the Internet");

} else {

InputStream is = httpConnection.openInputStream();

String response;

byte[] rawData;

getDataTime = System.currentTimeMillis();

// Now check on the encoding...

if (contentEncoding != null

&& contentEncoding.equals("gzip")) {

// The data is compressed

GZIPInputStream gzipInputStream = new GZIPInputStream(

is);

rawData = net.rim.device.api.io.IOUtilities

.streamToBytes(gzipInputStream);

unzipTime = System.currentTimeMillis();

response = new String(rawData);

} else {

unzipTime = getDataTime;

rawData = net.rim.device.api.io.IOUtilities

.streamToBytes(is);

response = new String(rawData);

}

responseTime = System.currentTimeMillis();

// Now we have string and bytes saved

unzipTime  = unzipTime - getDataTime;

getDataTime = getDataTime - getResponseTime;

getResponseTime = getResponseTime - getCOnnectionTime;

getCOnnectionTime = getCOnnectionTime - startTime;

Utils.log("Overall: " + responseTime - startTime) + "\n" +

"  Connection: " + getCOnnectionTime + "\n" +

"  Response: " + getResponseTime + "\n" +

"  Data: " + getDataTime + "\n" +

"  Unzip: + unzipTime);

 

Please use plain text.