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. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Java Development

Reply
New Contributor
necrocode
Posts: 4
Registered: ‎08-13-2010

Problem trying to connect with Sockets.

[ Edited ]

Hello everybody.

 

I am developing an application that connects to a server that I programmed and is responsible for receiving data that the phones send. Communication with the server I have implemented in cell phones through sockets. By using the J2ME APIs I tested the application in SonyEricson Mobile, Nokia and LG and it works perfectly, however when I run on the application in the BlackBerry that I have (BB 8520) although it says it has sent the data to the server, the server receives nothing from the BlackBerry. I have tried every possible connection parameters but there is no way that the program actually send the data, however, in the emulator if it works and the server receives the data. I consulted the forums and aprarentemente my implementation is correct and should work, but I do not know what else to try and I wonder if someone can give me some ideas of what might be done to solve the problem.

From now attached a piece of code if can help someone to identify the problem:


For the parameter PARAM I used the following strings

 

/*
A. PARAM = ";deviceside=true;apn=internet;tunnelauthusername=orange;tunnelauthpassword=orange";


B. PARAM =";deviceside=true;apn=internet;tunnelauthusername=;tunnelauthpassword=";


B. PARAM =";deviceside=true;apn=internet";


D.PARAM =";deviceside=true";


E.PARAM =";deviceside=false";


F.PARAM ="";

*/


SocketConnection _socketClient;

OutputStreamWriter flujoSalida;

boolean conectado;


try {
String ConnString = "socket://Server : port" + PARAM;
 _socketCliente = (SocketConnection)Connector.open(ConnString);
 conectado = true;
                        
 if (conectado) {
     flujoSalida = new OutputStreamWriter(_socketCliente.openOutputStream());
     String reporte = "Message I want to send";
     flujoSalida.write(reporte, 0, reporte.length());
     flujoSalida.flush();
     flujoSalida.close();
     _socketCliente.close();
  }

}
                
catch (SecurityException ex) {ex.getMessage()); }

catch (ConnectionNotFoundException ex) { ex.getMessage()); }
catch (IOException ex) {}
catch (Exception ex) {ex.getMessage()); }

 

 

In the emulator works when used as PARAM D. The BlackBerry send the information apparently when I use the D option. In cases A, B, C returns me error I / O Time Out.

In advance thank you very much for the time you read this post. I hope someone can help me

Please use plain text.
Developer
marchywka
Posts: 1,415
Registered: ‎07-30-2008

Re: Problem trying to connect with Sockets.

Have you tried BIS-B or whatever the RIM approach is called? It is supposed to

provide carrier independent stuff and seems to work better in general than

deviceside-true but what errors were you actually seeing on real device? Always

a timeout?  Depending on the carrier if you, gasp, go to multiple hosts, eventually

you usually get something like port already bound or dns error but not sure if

BIS-B fixes this or not since we finally went to sockets+proxies for everything.

on vz anyway deviceside=true works for a while anyway,

Please use plain text.
Developer
peter_strange
Posts: 17,718
Registered: ‎07-14-2008

Re: Problem trying to connect with Sockets.

Have you read this article, especially the section on Direct TCP, which seems to be what you are trying to use?

 

http://supportforums.blackberry.com/t5/Java-Development/Different-ways-to-make-an-HTTP-or-socket-con...

 

Since you are trying to specify APN information in your program, you should also read this:

http://supportforums.blackberry.com/t5/Java-Development/Specify-APN-information-for-a-direct-TCP-con...

 

Now the question is, are you using correct APN information for your network?

 

What is specified in your device's TCP Options?

Please use plain text.