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
Visitor
Posts: 1
Registered: ‎08-24-2010
My Device: Not Specified

Need help , HttpConnection problem (Forbiden 403 and Refused )

HI, 

 

dont know why 2 weeks ago, my http connection was fine with HttpConnectionFactory class (http://www.versatilemonkey.com/HttpConnectionFactory.java) and now my httpconnection still always refused on port 80

 

What the problem ? Carrier can refuse my connection ? which depend for this error ?

Before, i can fetch withour problem my json data with better download speed and today, it's not possible because this error.

Only way i managed to work , if i dont use "deviceside" in my url, it's working but kinda very slow Smiley Sad 

 

Thank in advane for help

 

my code :

 

try{

 

HttpConnectionFactory factory = new HttpConnectionFactory(homeURL, HttpConnectionFactory.DEFAULT_TRANSPORT_ORDER);

InputStream is= null;  

 

           try  

           {  

            HttpConnection connection = factory.getNextConnection();

connection.setRequestMethod("GET");

connection.setRequestProperty( "Content-type", "application/json" );

 

is = connection.openInputStream();

byte[] responseData = new byte[10000];

                     int length = 0;

                     //StringBuffer rawResponse = new StringBuffer();

                     while (-1 != (length = is.read(responseData))) {

                         content.append(new String(responseData, 0, length));

                     }

                     int responseCode = connection.getResponseCode();

                     if (responseCode != HttpConnection.HTTP_OK) {

                         throw new IOException("Invalid response code:" + responseCode);

                    }

                     String result = content.toString();

 

             }catch( Exception e ) {

//There are no more transports to attempt

Dialog.alert( "Unable to perform request" );

//Note you should never attemptnetwork activity on the event thread

}  

 } catch (Exception e) {  }