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


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
Highlighted
Developer
Posts: 300
Registered: ‎03-12-2009
My Device: Not Specified
Accepted Solution

ConnectionClosedException: Stream Closed

I have developed an app which uses the connection settings from "The Conntaction Thread".

 

I recently upgraded my OS to OS 5 from 4.6, and now the app is throwing an "ConnectionClosedException: Stream Closed" error all the time when connecting to certain aspects.

 

Is there a bug in OS5 for connections? What causes this problem?

 

Developer
Posts: 300
Registered: ‎03-12-2009
My Device: Not Specified

Re: ConnectionClosedException: Stream Closed

Code Bump:

 

 

	public c_ReturnObject GetForums(int forumid) throws Exception
	{
                // update the connection suffix
		updateConnectionSuffix();
		
		c_ReturnObject cro = new c_ReturnObject();
		Vector threadList = new Vector();
		
	    HttpConnection conn = null;
	    InputStream in = null;
	    
	    try
	    {      	    
	    	Document doc;

	    

	    	if 
	    		conn = (HttpConnection)Connector.open(Global.fselect.GetURL()+ Global.httpOptions);
	    
	    	
	        // set the cookie if one exists
	        if (Global.cookie != "")
	        	conn.setRequestProperty("Cookie",Global.cookie);
	        
	        DocumentBuilderFactory docBuilderFactory  = DocumentBuilderFactory. newInstance();
	        DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
	        docBuilder.isValidating();
	        
	        in = conn.openInputStream();
	        
	        doc = docBuilder.parse(in);
	        doc.getDocumentElement().normalize ();
	     
               /// do other things
		       
	        
	    }
	    catch (Exception e)
	    {
	    	throw e;
	    }
	    finally
	    {
	    	conn.close();
	    	in.close();
		    connectionRetry = 0;
	    }
	    
	    return cro;
	}

 

 

Developer
Posts: 300
Registered: ‎03-12-2009
My Device: Not Specified

Re: ConnectionClosedException: Stream Closed

Apperently this is a problem on OS 5.

 

http://forums.crackberry.com/f145/itookthisonmyphone-app-not-working-after-428-upgrade-385916/

 

Does anyone have a solution?!

Developer
Posts: 300
Registered: ‎03-12-2009
My Device: Not Specified

Re: ConnectionClosedException: Stream Closed

Looks like the problem lies somewhere around this line:

 

doc = docBuilder.parse(in);

 

If I comment out everything from there down, the code "works" (at least it connects and I don't get an error)..

 

If I pop it back in. .I get the Stream Closed error.

Developer
Posts: 300
Registered: ‎03-12-2009
My Device: Not Specified

Re: ConnectionClosedException: Stream Closed

Upon further testing, it seems that this is only happening "on occasion". 99 times out of 100.

 

Wtf?

 

Why is this only happening on OS5 ? And there has gotta be a work around!

 

Argh.

 

Wasted all night on this.

Developer
Posts: 300
Registered: ‎03-12-2009
My Device: Not Specified

Re: ConnectionClosedException: Stream Closed

This is whats happening in the log when it works:

 

 

#BlackBerry Event Log (cpt)
#HwID: 0x84000e07
#DPIN: 0x2094173e
#PVer: 5.2.0.33
#AVer: 5.0.0.411

a System - JVM:INFOp=2094173e,
a='5.0.0.411',o='5.2.0.33',h=84000e07 - 1/11 00:32:04 
a net.rim.tunnel - Clos-MagicRudyAPN.rim - 1/11 00:31:59 
a net.rim.tcp - clos - 1/11 00:31:59
a net.rim.tcp - disc   1 - 1/11 00:31:59
a net.rim.tunnel - STac-MagicRudyAPN.rim - 1/11 00:31:55 
a net.rim.tunnel - Open-MagicRudyAPN.rim - 1/11 00:31:55 
a net.rim.tcp - open - 1/11 00:31:55

 

 

This is whats going on when it's not working

 

 

#BlackBerry Event Log (cpt)
#HwID: 0x84000e07
#DPIN: 0x2094173e
#PVer: 5.2.0.33
#AVer: 5.0.0.411

a System - JVM:INFOp=2094173e,
a='5.0.0.411',o='5.2.0.33',h=84000e07 - 1/11 00:32:56 
a net.rim.tcp - clos - 1/11 00:32:53 
a net.rim.tunnel - Clos-MagicRudyAPN.rim - 1/11 00:32:53
a net.rim.tcp - disc   1 - 1/11 00:32:53
a net.rim.tunnel - STac-MagicRudyAPN.rim - 1/11 00:32:52 
a net.rim.tunnel - Open-MagicRudyAPN.rim - 1/11 00:32:52 
a net.rim.tcp - open - 1/11 00:32:52

 

 

Developer
Posts: 300
Registered: ‎03-12-2009
My Device: Not Specified

Re: ConnectionClosedException: Stream Closed

ARgh, I wanna smash this device tonight.

 

Bed.

 

 

Developer
Posts: 300
Registered: ‎03-12-2009
My Device: Not Specified

Re: ConnectionClosedException: Stream Closed

No one can help me with this? Am I the only one experincing this problem w/ their Bold on OS5?

Developer
Posts: 300
Registered: ‎03-12-2009
My Device: Not Specified

Re: ConnectionClosedException: Stream Closed

Well, I've tried like 9 different ways to get this data and I'm pretty much stuck ATM. ANY suggestions would be helpful.

 

Here's what I've tried

 

- Changed the InputStream to DataInputStream

- Copied the DataInputStream to a new DataInputStream

- Read each byte individually and read that to a InputStream

 

It seems when the "package" is under 2kb's, it works fine, but most of my requests are 10kb or so.

 

 

Developer
Posts: 300
Registered: ‎03-12-2009
My Device: Not Specified

Re: ConnectionClosedException: Stream Closed

Looks like docBuilder.parse(is); is throwing some sort of null error when you put it in it's own try/catch

 

try { doc = docBuilder.parse(is); } catch (Exception ex) {};

 

when you dont' put it in a try/catch is seems to work ont he simulator without fault, but not on the device.