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
Super Contributor
Posts: 253
Registered: ‎08-19-2010
My Device: BB10, Playbook, 9900, 9800, 9700, 9550, 9530, 9500, 8700.
My Carrier: TT

Does anyway check socket connection status?

In java EE,

 

socket.isconnected() can be used to check connection status.

 

I could not find a related class in the BlackBerry API.

 

if anyone knows it, please tell me.

 

Thanks your attention,

 

 

-Fight with BB10
Highlighted
Contributor
Posts: 28
Registered: ‎09-28-2011
My Device: 9700 Bold
My Carrier: Vodafone

Re: Does anyway check socket connection status?

Hello, I had a similar problem. Eventually my solution (although not elegant) was to create a "heartbeat" thread. The thread loops repeatedly and send an alive check message to the server. When the server receives the message it sends a reply back. If the thread doesn't receive the reply in a certain amount of time (in my case 5 seconds) it can assume that the connection is dead.

Hope it helps Smiley Happy
Contributor
Posts: 21
Registered: ‎02-10-2012
My Device: 8520, 9790
My Carrier: Airtel

Re: Does anyway check socket connection status?

Hello,

Can you please share the code or please explain the heartbeat process? how to send the request using heartbeat?

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

Re: Does anyway check socket connection status?

If you have a new question, please start a new Thread. 

 

A heartbeat message is not related to socket connections, it is a generic name for an application to application message, specific to those applications.   

Contributor
Posts: 21
Registered: ‎02-10-2012
My Device: 8520, 9790
My Carrier: Airtel

Re: Does anyway check socket connection status?

Thanks peter ,

 

and yes will start new thread for new question..

Developer
Posts: 709
Registered: ‎09-10-2009
My Device: 8520, 8900, 9000, 9300, 9650, 9700, 9780, 9800, 9810, 9900, 9930
My Carrier: Verizon

Re: Does anyway check socket connection status?


itsandybra wrote:
Hello, I had a similar problem. Eventually my solution (although not elegant) was to create a "heartbeat" thread. The thread loops repeatedly and send an alive check message to the server. When the server receives the message it sends a reply back. If the thread doesn't receive the reply in a certain amount of time (in my case 5 seconds) it can assume that the connection is dead.

Hope it helps Smiley Happy

Do you have any idea what that is going to do to the battery? The best is not to keep a connection opened. Instead, use the BB push notification if the server wants to talk to the client.