09-21-2011 01:43 AM
I am getting a ConnectionCloseException again and again if i halt to read from server for few minutes. Why am i getting this exception again n again. What more i need to concern about.
Thanks in advance.
09-21-2011 06:16 AM
My understanding is that the BlackBerry OS will kill a connection not used in the last 2 minutes. If you want to keep a connection alive (I presume this is a Stream connection), then send a heart beat type message.
But there is typically no need to keep a connection open, when you have services like Push. And this is not recommended practice if you wish to conserve battery life too. So perhaps another option is to review your application design and see if you can do what you need to do without keeping a connection open.
09-22-2011 01:27 AM
Can you please elaborate, how to keep this connection alive, what is this heart beat type message .... and how to implement it !! no knowledge about this.
09-22-2011 05:04 AM - edited 09-22-2011 05:06 AM
I'm not the best person to discuss this, because you will find that in the real world (like Java on the PC), the TCP/IP implementation can I believe be asked to provide this keep alive itself - but this is not something I am familiar with.
Unfortunately, actually deliberately, this is not implemented on the BlackBerry. So you have to do something yourself.
A heartbest message is just a simple 'I'm here' message that one end sends from time to time, The other end does not have to do anything with this, but should also reply, "I'm Here". That way both ends know that the other is still alive (hence the term heart beat).
But this message can also be used to keep connections alive, in situations where the ends (or an intervening gateway) will kill the connection if it thinks it is not active. This is the situation here. So the heart beat is being used to actually keep the connection alive, rather than being used as an indication of the state of health of the other end.
Hope this makes sense.
You will find more if you search the internet, here is quite a good discussion:
Edit: I realise I have missed your question about implementing this. You just have to agree a simple message that you or your Server will send from time to time, and the other end will respond to (but take no action on). That is all.