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: 47
Registered: ‎05-06-2009
My Device: Not Specified

net.rim.device.api.io.CommectionClosedException: Bad socket id

[ Edited ]

Hi there!

 

This is me again!

I reviewed some threads in this forum, but I could not solve the problem:

 

I have a socket connection to a winsock socket. The connection works fine, but after a random (can't find something that could cause it) time I get this exception:

net.rim.device.api.io.CommectionClosedException: Bad socket id

 

It's really confusing me, this is the simplified part where the connection is breaking down:

 

try
{
connection = (StreamConnection)Connector.open(url);
_in = new InputStreamReader(connection.openInputStream());
_out = new OutputStreamWriter(connection.openOutputStream());

while (! isInterrupted())
{
// send and receive something
}
}
catch (IOException e)
{
// exception handler <---------- Problem
}

 

Can you explain me what that means or better, what causes this?

Thank you in addition!

 

 

 //Edit: Ah, I forgot to say that this happens only on the real device!

Message Edited by ShadowMare on 10-09-2009 10:26 AM
Developer
Posts: 3,951
Registered: ‎07-15-2008
My Device: Not Specified

Re: net.rim.device.api.io.CommectionClosedException: Bad socket id

Check is that after a certian time period or something.

Use Search. "Accept Solution" If the problem is resolved.
Developer
Posts: 47
Registered: ‎05-06-2009
My Device: Not Specified

Re: net.rim.device.api.io.CommectionClosedException: Bad socket id

Thank you for your reply.

I can't see a "time pattern" for that problem, but it is not often. It's not that big problem Smiley Happy

Developer
Posts: 3,951
Registered: ‎07-15-2008
My Device: Not Specified

Re: net.rim.device.api.io.CommectionClosedException: Bad socket id

Ok, hope you have put the mechanisam to create a new connection after the connection gets closed and send data again.

Use Search. "Accept Solution" If the problem is resolved.
Developer
Posts: 47
Registered: ‎05-06-2009
My Device: Not Specified

Re: net.rim.device.api.io.CommectionClosedException: Bad socket id

Of course Smiley Happy

I was just interested if someone knows what causes this. But it is not noticeable at all!

Developer
Posts: 1,474
Registered: ‎04-14-2009
My Device: Not Specified

Re: net.rim.device.api.io.CommectionClosedException: Bad socket id

I'm speculating here, but I think that the most part of the BlackBerry TCP layer is implemented in native code and socket IDs/handles are exposed to the JVM for working with TCP streams. When the JVM attempts to send something via a socket that is no longer there in the native layer, the stack replies with "bad socket id".
Developer
Posts: 709
Registered: ‎09-10-2009
My Device: 8520, 8900, 9000, 9300, 9650, 9700, 9780, 9800, 9810, 9900, 9930
My Carrier: Verizon

Re: net.rim.device.api.io.CommectionClosedException: Bad socket id

shadowmare, how often are you sending and receive data? BB tcp is no tcp, it is a tunnel to a gateway. The gateway is doing the tcp , not the BB  device.
Developer
Posts: 1,474
Registered: ‎04-14-2009
My Device: Not Specified

Re: net.rim.device.api.io.CommectionClosedException: Bad socket id

[ Edited ]

No, in the case of Direct TCP (deviceside=true) the tunnel is IP. The device itself is generating TCP packets and processing the received TCP packets.

Message Edited by klyubin on 13-10-2009 04:56 AM
Developer
Posts: 47
Registered: ‎05-06-2009
My Device: Not Specified

Re: net.rim.device.api.io.CommectionClosedException: Bad socket id

Sounds interesting Smiley Happy

Yes it is deviceside=true; and im using WAP2.

 

The amout of data is unsteady, depends on the state of my application. I would say it is average 100kb per minute. This exception is not depending of the coverage (I think) because that would give me another one.

Developer
Posts: 1,474
Registered: ‎04-14-2009
My Device: Not Specified

Re: net.rim.device.api.io.CommectionClosedException: Bad socket id

WAP 2.0 TCP also uses a (modified) TCP stack on the device.