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
Developer
zinzinzan
Posts: 90
Registered: ‎04-03-2012
My Device: 9100
My Carrier: movilnet

Push registration, time out Exception

Hi there, i tried some push client code from author simon_hain of supportforums.blackberry.com, and i get IO.Exception on register method caused by Timed out i dont know what to do :smileyfrustrated:, i follow all the indications, change the app ID, the port for e-mail info, and delete the atribute private static final String CONNECTION_SUFFIX = ";deviceside=false"; because i need dont need msd or bes connection i need bis: here is the code:

private void registerBpas() {
		final String registerUrl = formRegisterRequest(BPAS_URL, APP_ID, null);
		/**
		 * As the connection suffix is fixed I just use a Thread to call the connection code
		 * 
		 **/
		new Thread() {
			public void run() {
				try {
					HttpConnection httpConnection = (HttpConnection) Connector.open(registerUrl);
					InputStream is = httpConnection.openInputStream();
					String response = new String(IOUtilities.streamToBytes(is));
					close(httpConnection, is, null);
					String nextUrl = formRegisterRequest(BPAS_URL, APP_ID, response);
					HttpConnection nextHttpConnection = (HttpConnection) Connector.open(nextUrl);
					InputStream nextInputStream = nextHttpConnection.openInputStream();
					response = new String(IOUtilities.streamToBytes(nextInputStream));
					close(nextHttpConnection, is, null);
					if (REGISTER_SUCCESSFUL.equals(response) || USER_ALREADY_SUBSCRIBED.equals(response)) {
						System.out.println("Registered successfully for BIS push");
						dialogo("Registered successfully for BIS push");
					} else {
						dialogo("BPAS rejected registration");
						System.out.println("BPAS rejected registration");
					}
				} catch (IOException e) {
					dialogo("IOException on register() " + e + " " + e.getMessage());
					System.out.println("IOException on register() " + e + " " + e.getMessage());
				}
			}
		}.start();
	}

 

 

Please use plain text.
Developer
Dionysus
Posts: 152
Registered: ‎07-28-2011
My Device: Bold 9900
My Carrier: MTN

Re: Push registration, time out Exception

On this line:

 

close(nextHttpConnection, is, null);

 

change to:

 

close(nextHttpConnection, nextInputStream, null);

 

 

So your code will look exactly the same but the InputStream you're trying to close is incorrect on the nextHttpConnection.

 

private void registerBpas() {
		final String registerUrl = formRegisterRequest(BPAS_URL, APP_ID, null);
		/**
		 * As the connection suffix is fixed I just use a Thread to call the connection code
		 * 
		 **/
		new Thread() {
			public void run() {
				try {
					HttpConnection httpConnection = (HttpConnection) Connector.open(registerUrl);
					InputStream is = httpConnection.openInputStream();
					String response = new String(IOUtilities.streamToBytes(is));
					close(httpConnection, is, null);
					String nextUrl = formRegisterRequest(BPAS_URL, APP_ID, response);
					HttpConnection nextHttpConnection = (HttpConnection) Connector.open(nextUrl);
					InputStream nextInputStream = nextHttpConnection.openInputStream();
					response = new String(IOUtilities.streamToBytes(nextInputStream));
					close(nextHttpConnection, nextInputStream, null);
					if (REGISTER_SUCCESSFUL.equals(response) || USER_ALREADY_SUBSCRIBED.equals(response)) {
						System.out.println("Registered successfully for BIS push");
						dialogo("Registered successfully for BIS push");
					} else {
						dialogo("BPAS rejected registration");
						System.out.println("BPAS rejected registration");
					}
				} catch (IOException e) {
					dialogo("IOException on register() " + e + " " + e.getMessage());
					System.out.println("IOException on register() " + e + " " + e.getMessage());
				}
			}
		}.start();
	}

 

Please use plain text.