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
Posts: 571
Registered: ‎04-11-2009
My Device: BB 10 Dev Alpha

BIS+PushAgent+Failed to open Port+IOPortAlreadyBoundException

Hi experts,

 

I am using http://supportforums.blackberry.com/t5/BlackBerry-Push-Development/Simplified-BIS-Push-client-sample... this one for my BIS client.

 

But I am facing 1  issue that is  

 

Failed to open port, caused by net.rim.device.api.io.IOPortAlreadyBoundException: Port [XXXXX] is unavailable.

 

I found a thread having similar issue - http://supportforums.blackberry.com/t5/BlackBerry-Push-Development/Port-used-by-another-application/..., but the solution is not working for me..

 

Please shed some light..

 

Regards,
Kanak Sony
------------------------------------------------------------------------------------------
http://dodevelopnshare.wordpress.com/ | http://www.linkedin.com/profile/view?id=188131481&trk=tab_pro
Developer
Posts: 17,011
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: BIS+PushAgent+Failed to open Port+IOPortAlreadyBoundException

a single port can only be opened once, and if it is used by another application or was not properly closed it cannot be opened again.

i usually have my pushlistener in the autostart to avoid it registering twice.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 571
Registered: ‎04-11-2009
My Device: BB 10 Dev Alpha

Re: BIS+PushAgent+Failed to open Port+IOPortAlreadyBoundException

Thanks for the quick reply Simon..

 

Yes, the proble is it is not being closed properly.. 

 

I have this scenario - 

 

From my main App,

 

MMPushDemoAppMain(){
	
		homeScreenInstance = new HomeScreen();

		new PushAgent(homeScreenInstance);

		UiApplication.getUiApplication().pushScreen(homeScreenInstance);

}

 

 

public PushAgent(HomeScreen homeScreenInstance) {
		this.homeScreenInstance = homeScreenInstance;
		
		registerBpas();

		messageReadingThread = new MessageReadingThread();
		messageReadingThread.start();

	}

	/**
	 * @return
	 */
	public static void quitPushAgent() {
		if(messageReadingThread!=null)
			messageReadingThread.stopRunning();
	}

 

 

public boolean onClose()
{
		System.out.println(" ------- on close ---------------");
		PushAgent.quitPushAgent();
		return true;
}

 

This is how I am trying to close SocketConnection object, but the problem persists...

Regards,
Kanak Sony
------------------------------------------------------------------------------------------
http://dodevelopnshare.wordpress.com/ | http://www.linkedin.com/profile/view?id=188131481&trk=tab_pro
Developer
Posts: 17,011
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: BIS+PushAgent+Failed to open Port+IOPortAlreadyBoundException

as i suggested you could put your listener into an autostart part, or use a runtimestore singleton to ensure that it is only used once.
i use global events to communicate from the push listener to my app.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Highlighted
Developer
Posts: 571
Registered: ‎04-11-2009
My Device: BB 10 Dev Alpha

Re: BIS+PushAgent+Failed to open Port+IOPortAlreadyBoundException

Thanks Simon.. I will try and will post the results..

Regards,
Kanak Sony
------------------------------------------------------------------------------------------
http://dodevelopnshare.wordpress.com/ | http://www.linkedin.com/profile/view?id=188131481&trk=tab_pro