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

Posts: 10
Registered: ‎05-09-2012
My Device: 9780
My Carrier: T-Mobile USA

Problem with http connection

Hello everyone, I'm having problems with network http connectivity.
Specifically, my app works fine for a while, it connects with no problems, works fine, it could be working for hours, but then all of a sudden it won't connect anymore.
I try and try but it is not connecting. While my app is not connecting I try to use the phone's web browser or google maps ant they both work but my app won't.
The only way to restore the app's connectivity is by disconnecting and connecting from the network using the phone's "manage connections" dialog or by power-cycling the phone.
Then the app works againg for a while and the cycle repeats.

The carrer is T-Mobile (if that matters at all)

Here is a snippet of my code for the connection does that look fine? Or do you see anything wrong on it?


    public void data() {
        ConnectionFactory connFact = new ConnectionFactory();
        // Try only the following transport types:
        int[] transportTypes = {
        ConnectionDescriptor connDesc;
        connDesc = connFact.getConnection("http://some.web.server.net/index.php");
        // ------------ Connect
        if (connDesc != null) {
            HttpConnection httpConn;
            httpConn = (HttpConnection)connDesc.getConnection();
            try {
                int _rspnseCode = httpConn.getResponseCode();
                message = httpConn.getHeaderField("message");
                if (_rspnseCode != 200){
                    _localError = "http error "+_rspnseCode;
            }catch (IOException e){
                _localError = "http error";

Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Problem with http connection

Don't see you closing the connection.  Can I suggest you have a finally that tidies this up (and anything else you allocate). 

Posts: 10
Registered: ‎05-09-2012
My Device: 9780
My Carrier: T-Mobile USA

Re: Problem with http connection

Good point Peter, I forgot to close the connection, that could be the reason, thanks a lot!