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

Regular Visitor
Posts: 1
Registered: ‎12-15-2009
My Device: Not Specified

HTTPConnection slowness on 4.5 API



I am having troubles with my application on devices running the 4.5 API.  Everything is looking fine on devices running 4.6, 4.7, and also looks fine on simulators running 4.5+. 


Background:  I am attempting to create a streaming player for audio (wav) files.  These files are being obtained from a web service, and uses http cookie authentication before any audio is sent back to the blackberry client app.


To accomplish this, I have referenced 2 of the sample demos available in the JDE: HTTPDemo (4.5 jde - for http authentication) and BufferedPlaybackDemo (4.6 jde - for streaming purposes).


The issue I am running into looks tied with the http authentication.  With these samples implemented, I can successfully stream an audio file that requires no authentication.  When adding authentication, however, a lot more slowness is introduced to the java application.


 In the block below, on devices running the 4.5 api, there is one main issue:  There is a 4-9 second delay after both the initial Connector.open() call, as well as another pause when casting that connector to an HttpsConnection.  This delay looks tied to network latency, but it seems odd that this operation would take so long while the connection is still in the 'setup' mode and hasn't yet connected to the remote url.



s = (StreamConnection)Connector.open(getLocator());
HttpsConnection httpConn = ( HttpsConnection)s;
httpConn.setRequestProperty( "cookie", requestCookie.toString());


Another issue I am encountering deals with attempting to read data from an input stream.  On a separate thread from the Event thread, I am trying to read into a byte[] buffer, using



_inputStream.read( buf)


On the very first call of this, and after every ~12-16k of data has been transmitted, the read() will block for 20-30 seconds, and will continue working after.  All told, an 8120 pearl takes about 75s to authenticate and download a 40k file, while a 9000 bold can accomplish the same in 8s running off the same codebase.




My questions are as follows:


1) Is there an alternate method for cookied authentication rather than using Http/sConnection?  I assume that there should be a more speedy way to authenticate, the hard part is finding it.


2) Are there any other reference materials for accomplishing streaming with authentication, which will work on 4.5?  The majority of the articles I have seen refer to streaming in 4.6+, and have limited usability on a 4.5 device.


3) Occasionally I will see a message in the event log saying 'a net.rim.tcp - disc  1'.  I cannot find much information on this event - is it anything to worry about?




Thank you for your time,

  - Cory

Posts: 1,415
Registered: ‎07-30-2008
My Device: Not Specified

Re: HTTPConnection slowness on 4.5 API

This is interesting if it is a true version specific issue. I've had a lot of problems with calls to getResponseCode() but you expect there to be some network issues. The lack of net tools by design, like traceroute, makes it hard to tell where the problem is, it could still be on the phone

or in a gateway/proxy somewhere but you can't tell.