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
s_miller
Posts: 6
Registered: ‎09-27-2009
My Device: Not Specified

SSL ConnectionNotFoundException

[ Edited ]

Hello,

 

I am getting a strange error when opening a ssl connection to a server. The error occurs both on the simulator and the actual device (BB 8310, V4.5). The first time the connection is established, it functions correctly. When the application exits, the disconnect function is triggered and returns no exceptions. However, when trying to reconnect i recieve the error javax.microedition.io.ConnectionNotFoundException. If I erase the simulator files and run the appliction again it functions correctly, but again, only the first time. I found a post with the same problem but no answer. However, if i run the same application on the 8900 or 9000 simulator or device, the connection functions correctly each time.

 

 

private void connect()throws Exception{
String ipAddress = loadIP();
String url = "ssl://" + ipAddress + ":9876;deviceside=true";
connection = (SecureConnection)Connector.open(url);
_out = new StringOutputStream (new DataOutputStream(connection.openOutputStream()));
_out.flush();
_in = new StringInputStream (new DataInputStream(connection.openInputStream()));
read = new readThread();
read.start();
}

public void disconnect(){
try{
_in.close();
}catch(Exception e3){
System.out.println("_IN.CLOSE() EXCEPTION: "+e3.toString());
}

try{
_out.close();
}catch(Exception e2){
System.out.println("_OUT.CLOSE() EXCEPTION: "+e2.toString());
}

try{
connection.close();
}catch(Exception e4){
System.out.println("CONNECTION.CLOSE() EXCEPTION: "+e4.toString());
}

}

 

 

 The actual exception is thrown by the line:

connection = (SecureConnection)Connector.open(url);

 

 

Message Edited by s_miller on 09-27-2009 05:06 PM
Please use plain text.
Developer
Posts: 1,474
Registered: ‎04-14-2009
My Device: Not Specified

Re: SSL ConnectionNotFoundException

[ Edited ]
Don't know whether this'll help, but try tls:// instead of ssl://. Also, make sure you log the connection URL passed into Connector.open just to see whether your app is generating a weird-looking URL the second time the app runs.
Message Edited by klyubin on 28-09-2009 11:43 AM
Please use plain text.
New Developer
s_miller
Posts: 6
Registered: ‎09-27-2009
My Device: Not Specified

Re: SSL ConnectionNotFoundException

Same error occurs whether using tls or sll. The url being passed to Connector.open is no different between successful runs and non successful runs.
Please use plain text.
New Developer
s_miller
Posts: 6
Registered: ‎09-27-2009
My Device: Not Specified

Re: SSL ConnectionNotFoundException

I trimmed out all extraneous code to test the connection and the issue still occurs. Here is the entire code that produces the javax.microedition.io.ConnectionNotFoundException in v4.5

 

import java.io.*; import net.rim.device.api.ui.UiApplication; import javax.microedition.io.*; class TestApp extends UiApplication{ SecureConnection connection = null; public static void main(String[] args){ new TestApp().enterEventDispatcher(); } public TestApp() { try{ connect(); }catch(Exception e){ System.out.println("CONNECT 1 ERROR: "+e.toString()); } try{ disconnect(); }catch(Exception e){ System.out.println("DISCONNECT ERROR: "+e.toString()); } try{ connect(); }catch(Exception e){ System.out.println("CONNECT 2 ERROR: "+e.toString()); } } private void connect()throws Exception{ connection = (SecureConnection)Connector.open("ssl://10.192.72.131:9876;deviceside=true"); } public void disconnect()throws Exception{ connection.close(); } }

Output in v4.5:

 

Started TestApp(156)
Foreground TestApp(156)
SSL:->CH
SSL:<-SH
SSL:<-SKE
SSL:<-SHD
SSL:->CKE
SSL:->CCS
TLS:->F
TLS:<-F
SSL: Ok
CONNECT 2 ERROR: javax.microedition.io.ConnectionNotFoundException

 

Output in v4.6:

 

Started TestApp(211)
Foreground TestApp(211)
SSL:->CH
SSL:<-SH
SSL:<-SKE
SSL:<-SHD
SSL:->CKE
SSL:->CCS
TLS:->F
TLS:<-F
SSL: Ok
SSL:->CH
SSL:<-SH
SSL:<-SKE
SSL:<-SHD
SSL:->CKE
SSL:->CCS
TLS:->F
TLS:<-F
SSL: Ok

 

Any help on this would be greatly appreciated!

Please use plain text.
Developer
Posts: 1,474
Registered: ‎04-14-2009
My Device: Not Specified

Re: SSL ConnectionNotFoundException

[ Edited ]

Interesting!

 

Try the following two things separately:

 

1. Add a delay (say, 10 seconds) between the first disconnect() and the second connect().

 

2. Establish a socket:// connection to the same IP+port, then wrap it into a TLS10Connection using "new TLS10Connection(socketConnection)".

Message Edited by klyubin on 28-09-2009 09:39 PM
Please use plain text.
New Developer
s_miller
Posts: 6
Registered: ‎09-27-2009
My Device: Not Specified

Re: SSL ConnectionNotFoundException

1. The time difference does not appear to have any effect on the appearance of the ConnectionNotFoundException

 

2.  Exact same behaviour on the 8310. The connection functions as expected the first time, and then any subsequent reconnections fail. The exception given now though is Java.lang.illegalArgumentException. I have verified that the arguments being passed are the same for a successful run and a non successful run. Again, the TLS10Connection functions correctly for each connection on the BB 9000, v4.6

Please use plain text.
Developer
Posts: 1,474
Registered: ‎04-14-2009
My Device: Not Specified

Re: SSL ConnectionNotFoundException

[ Edited ]

Where does the IllegalArgumentException occur (Connector.open or TLS10Connection)? Would you please post the stack trace?

 

P.S. You can obtain the stack trace by catching Throwable instead of Exception. In this case the stack trace will automatically be logged in the EventLog and the Debugger will also break (by default) as soon as the exception is thrown.

Message Edited by klyubin on 29-09-2009 12:57 AM
Please use plain text.
New Developer
s_miller
Posts: 6
Registered: ‎09-27-2009
My Device: Not Specified

Re: SSL ConnectionNotFoundException

[ Edited ]

IllegalArgumentException occurs at TLS10Connection.

 

Stack Trace:

 

CertificateChainFactory.createCertificateChains( Certificate, Certificate[], KeyStore, String )
CertificateUtilities.buildCertificateChains( Certificate, Certificate[], KeyStore, String )
CertificateUtilities.buildCertificateChains( Certificate, Certificate[], KeyStore )
SSLHandshakeProtocol.determineBestCertificateChainProperties( Certificate, Certificate[] )
SSLHandshakeProtocol.clientHello(  )
SSLHandshakeProtocol.connect(  )
SSLRecordProtocol.connect(  )
TLS10Connection.TLS10Connection( StreamConnection, String, boolean, TLSRecordProtocol )
TLS10Connection.TLS10Connection( StreamConnection, String, boolean )
TLS10Connection.TLS10Connection( StreamConnection, String )

 

Locals:

 

Name:    Value:    Type:

Exception thrown:    @303F4000    java.lang.IllegalArgumentException
certificate    null    net.rim.device.api.crypto.certificate.Certificate
certificatePool    null    Certificate[]
emailAddress    null    java.lang.String

 

 

===================================================================

 

When switching the connection back to:

 

 

String url = "ssl://" + ipAddress + ":9876;deviceside=true;"; connection = (SecureConnection)Connector.open(url);

 

Here is the stack trace produced when i get ConnectionNotFoundException:

 

Protocol.doConnection( URL, int, boolean )
Protocol.openPrim( String, int, boolean )
RIMConnector.open( int, String, int, boolean, FirewallContext )
RIMConnector.open( int, String, int, boolean )
Connector.open( String, int, boolean )
Protocol.openPrim( String, int, boolean )
RIMConnector.open( int, String, int, boolean, FirewallContext )
RIMConnector.open( int, String, int, boolean )
Connector.open( String )

 

Locals:

 

 Name:    Value:    Type:
Exception thrown:    @4BDE2000    javax.microedition.io.ConnectionNotFoundException
hostName    @4C35A000 "192.168.0.101"    java.lang.String
mode    3    int
port    9876    int
startHandshake    true    boolean

 

 

 

Message Edited by s_miller on 09-28-2009 09:49 PM
Please use plain text.
Developer
Posts: 1,474
Registered: ‎04-14-2009
My Device: Not Specified

Re: SSL ConnectionNotFoundException

You may want to submit this to RIM's Developer Issue Tracker.
Please use plain text.
New Developer
s_miller
Posts: 6
Registered: ‎09-27-2009
My Device: Not Specified

Re: SSL ConnectionNotFoundException

Thanks for all your assistance with this issue. I have submitted it to the issue tracker. In case you're interested in the outcome, here is the link: https://www.blackberry.com/jira/browse/JAVAAPI-464
Please use plain text.