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
footose
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?

 

Please use plain text.
Developer
footose
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;
	}

 

 

Please use plain text.
Developer
footose
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?!

Please use plain text.
Developer
footose
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.

Please use plain text.
Developer
footose
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.

Please use plain text.
Developer
footose
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

 

 

Please use plain text.
Developer
footose
Posts: 300
Registered: ‎03-12-2009
My Device: Not Specified

Re: ConnectionClosedException: Stream Closed

ARgh, I wanna smash this device tonight.

 

Bed.

 

 

Please use plain text.
Developer
footose
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?

Please use plain text.
Developer
footose
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.

 

 

Please use plain text.
Developer
footose
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.

 

 

 

Please use plain text.