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
New Developer
Posts: 51
Registered: ‎04-23-2009
My Device: Not Specified

Re: http close outputstream will close whole connection.

NoCopyByteArrayOutputStream, this is an interesting class.

 

I don't think it related with the question I asked, but it didn't help us to solve our other problems. ^_^ Thanks.

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

Re: http close outputstream will close whole connection.

If all else fails, I suggest you analyze the HTTP traffic -- see if the server receives the request and whether it sends the response. If not, have a look at the TCP traffic to see who's shutting down the connection in which direction and when.

New Developer
Posts: 51
Registered: ‎04-23-2009
My Device: Not Specified

Re: http close outputstream will close whole connection.

How can I get HTTP/TCP traffic from device?

 

Thanks.

Developer
Posts: 1,305
Registered: ‎01-21-2009
My Device: Not Specified

Re: http close outputstream will close whole connection.

If you have access to a device that is having the problem, you can debug the application while it is running on the device.




Solved? click "Accept as solution". Helpful? give kudos by clicking on the star.
Highlighted
Developer
Posts: 101
Registered: ‎05-11-2009
My Device: 9000

Re: http close outputstream will close whole connection.

[ Edited ]

But how are you actually writing the data to the OutputStream ? I mean maybe packet is formatted incorrectly or server returns something that breaks the connection.

 

Maybe you should open output and input stream when you create the connection first, like in this example:

 

 

SocketConnection sc = (SocketConnection)
                         Connector.open("socket://host.com:79");
   sc.setSocketOption(SocketConnection.LINGER, 5);

   InputStream is  = sc.openInputStream();
   OutputStream os = sc.openOutputStream();

   os.write("\r\n".getBytes());
   int ch = 0;
   while(ch != -1) {
       ch = is.read();
   }

   is.close();
   os.close();
   sc.close();

 Do you have any example how to make SocketConnection with HTTP Post, for some reason I am always getting ConnectionClosedException when I write data to the OutputStream !

 

 

 

Contributor
Posts: 35
Registered: ‎10-06-2010
My Device: Bold 9650
My Carrier: Verizon

Re: http close outputstream will close whole connection.

I've exeperienced the same behavior as the OP. After writing to a SocketConnection via an OutputStream opened on the connection, I was closing the OutputStream. When I attempted to then read from an InputStream that was opened via the same SocketConnection, a ConnectionClosedException was thrown. The only way around this behavior was to simply not close any of the streams opened from the connection until all reading and writing was complete.

Joe Davis
Developer | Metova
http://www.metova.com