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

BlackBerry Push Development

Reply
Contributor
siddupatil
Posts: 23
Registered: ‎03-17-2014
My Device: 9220

Registering for PushNotification failing with HTTP Response Code 502 ... !!!!

While client is requesting for registering  with BlackBerry server, i am getting 502 as http response code.  This used to work until last week and now getting 502 error code with no changes whatsoever in the code or with the Credentials .

 

following is the code from the pushdemo that i downloaded from 

 

https://developer.blackberry.com/devzone/develop/platform_services/sample_push_service_applications....

 

 

here is the code.

 

publicstatic String request( String httpUrl, Transaction tx ) throws IOException {

        checkTransaction( tx );

       

        DataBuffer buffer = new DataBuffer( 256, false );

        InputStream is = null;

        Connection conn = null;

        try {

            // append connection suffix

            httpUrl += getConnectionSuffix();

            Logger.log( "Opening URL: " + httpUrl );

            conn = Connector.open( httpUrl );

            tx.setNetworkOperation( conn, is );

            if( conn instanceof HttpConnection ) {

                HttpConnection httpConn = (HttpConnection) conn;

                int responseCode = httpConn.getResponseCode();

                is = httpConn.openInputStream();

                tx.setNetworkOperation( conn, is );

                int length = is.read( buffer.getArray() );

                buffer.setLength( length );

 

                String response = new String( buffer.getArray(), buffer.getArrayStart(), buffer.getArrayLength() );

               

                System.out.println(" response = "+response);     --------->   Here the response is 502.

                if( responseCode == 200 ) {

                    Logger.log( "HTTP response: " + response );

                    return response;

                } else {

                    //Logger.warn( "HTTP error response: " + response );

                    System.out.println("HTTP error response: " + response);

                    thrownew IOException( "Http error responseCode : " + responseCode + ", " + response );                 

                   

                }

            } else {

                thrownew IOException( "Can not make HTTP connection for URL '" + httpUrl + "'" );

            }

        } finally {

            PushUtils.close( conn, is, null );

            tx.clearNetworkOperation();

        }

    }

 

if anyone had hit the same road block before, i am listening...........................:Helpsmilie:  

BlackBerry Development Advisor
twindsor
Posts: 832
Registered: ‎07-15-2008
My Device: Passport
My Carrier: Bell

Re: Registering for PushNotification failing with HTTP Response Code 502 ... !!!!

This is logged internally now as BBNOSSE-7861

Tim Windsor
Open Source Technical Lead