01-10-2010 02:41 PM
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?
Solved! Go to Solution.
01-10-2010 10:52 PM
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.GetU RL()+ 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;
}
01-10-2010 11:39 PM
Apperently this is a problem on OS 5.
http://forums.crackberry.com/f145/itookthisonmypho
Does anyone have a solution?!
01-10-2010 11:56 PM
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.
01-11-2010 12:30 AM
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.
01-11-2010 12:35 AM
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
01-11-2010 02:01 AM
ARgh, I wanna smash this device tonight.
Bed.
01-11-2010 09:05 AM
No one can help me with this? Am I the only one experincing this problem w/ their Bold on OS5?
01-11-2010 10:11 AM
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.
01-11-2010 11:31 AM
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.