11-11-2008 11:43 AM
Although there are different positng I cannot get my java program to run! My BB 8800 is setup with an BES. Our intranet is blocking socket connections on the port 2001 (the one I am trying). Hence I am trying to use direct TCP.
I am using the socket.java from the samples (just removed the receiving part), set up my TCP APN (T-mobile Germany: internet.t-mobile, user: t-mobile, password: tm) in my BB and have the following code:
...
_screen.updateDisplay("Opening Connection...");
String url = "socket://" + _screen.getHostFieldText() + ":2001" + (_screen.isDirectTCP() ? ";apn=internet.t-mobile;TunnelAuthUsername=t-mobil
_screen.updateDisplay("Connect to "+url);
connection = (StreamConnection)Connector.open(url);
_screen.updateDisplay("Connection open");
//_in = new InputStreamReader(connection.openInputStream());
_out = new OutputStreamWriter(connection.openOutputStream());
_screen.updateDisplay("Send string");
// Send the HELLO string.
exchange("Hello");
...
The host is an IP address. I tried direct TCP socket communication (checkbox marked in UI) as well indirect.
1) not direct: communication established, characters send (assumed by BB) but nothing arrives at the server!
2) direct: socketdemo hangs while trying to connect
The server side is a simple, multithreaded socket listener, which works fine (tested).
...
Socket clientSocket = null;
try {
System.out.println("SimpleSocketServer.WaitingForC
clientSocket = serverSocket.accept(); //blocking call - waits for a connection
System.out.println("SimpleSocketServer.ClientConne
} catch (IOException e) {
System.err.println(e);
System.exit(-1);
}
...
Could someone please help me? I tried nearly everthing.
Regards
R
11-11-2008 12:20 PM
Is your URL mising ";deviceside=true"?
I presujme, since you are using direct TCP, that the IP Address you are using is externally addressable - in other words, if I knew your URL, I could connect - is this true?
11-12-2008 04:26 AM
Yes my url contains "deviceside=true":
String url = "socket://" + _screen.getHostFieldText() + ":2001" + (_screen.isDirectTCP() ? ";apn=internet.t-mobile;TunnelAuthUsername=t-mobil
11-12-2008 04:42 AM
Apologies, I expect to see deviceside=true at the start of the connection string so missed it...
I think using IP Address is fine, I do that with socket connections.
I've done a quick look round for the APN settngs for tMobile in Germany, and I get a varierty of different settings. How have you determined the ones that you use?
11-12-2008 04:58 AM
I also tried different settings for T-Mobile. The one that I am currently using (internet.t-mobile, t-mobile, tm) are successfully tested with a different GPS/GPRS device.
Actually I am wondering about the facts, that
1- there is no error message when using not direct TCP, but the socketdemo assumes that everything is successfully sent.
2- there is not timeout but the program just hangs if there is direct TCP
11-12-2008 05:23 AM
I agree, those are both odd. I would have expected a timeout at least for the direct TCP. What OS level do you have in your 8800? Do you have any other devices you can test on?
DO you have this available as a OTA download, if so perhaps I would try it?
11-12-2008 05:53 AM
Blackberry 8800
V4.2.1.120 (Platform 2.3.0.80)
Unfortunately I do not have the option to provide the program via OTA. I could send it via email.... Do you want to see the source?
11-12-2008 06:23 AM
I have an 8800, 4.2.1.68, 2.3.0.54 I can stick it on here.
On reflection, that was a silly idea to suggest I could run your code directly - you have tMobile Germany settings and I'm on Vodafone UK! So I will probably need the source so I can change it, unless you want to hard code the Voda settings
";apn=internet;tunnelauthusername=web;tunnelauthpa
Alternatively, you can just remove the apn settings completely, then I can code what I need in the TCP Options on the device.
11-12-2008 11:59 AM
Actually I enhanced the exception handling (formerly only System.err.println(e.toString()); - showing nothing) and the openConnection url by mode and timeout parameter
connection = (StreamConnection)Connector.open(url, Connector.READ_WRITE, timeouts);
Now I am getting at least an exception message: "Unable to open connection" in direct TCP mode when showing
catch(IOException e)
{
_screen.updateDisplay("IOException: " + e.getMessage());
e.printStackTrace();
System.err.println(e.toString());
}
But still I have no clue why the connection is not possible.
11-13-2008 10:53 AM
PROBLEM Solved.
tried it on port 80 and it worked, hence checked the firewall, which was enabled! After disabling it (/etc/config.d/iptables disable) it worked well.
thx for support and ideas!