APN cached

90 views
Skip to first unread message

eppie

unread,
Sep 16, 2013, 5:58:16 AM9/16/13
to java...@googlegroups.com
Hello,

I still have some problems with modules who spontaneously cannot connect anymore to the GPRS network with the exception ' Profile could not be activated' . So I decided to build in a function that will test multiple APN's and send the result by SMS back to me.
No I notice that when I use the SocketConnection class and provide APN information with it, it looks like it is cached when a working APN is found!

In the example beneath ONLY the result will be;
internet --> error
live.vodafone.com --> OK
others --> OK

This is very strange because of the fact that only the live.vodafone.com APN is inteded for the used sim and is also the only one who works! If I change the order the result is that everything works after the live.vodafone.com apn is used!

Anyone noticed this??

Enter
 
private void testCommunication(String nr) {
       
//Request settings
       
Settings settings = Settings.getInstance();
       
String host = settings.getString("server.host");
       
int port = settings.getInt("server.port");

        sendSms
(new SMS(nr, testCommunicationApn(host, port, "internet", "", "")));
        sendSms
(new SMS(nr, testCommunicationApn(host, port, "live.vodafone.com", "vodafone", "vodafone")));
        sendSms
(new SMS(nr, testCommunicationApn(host, port, "office.vodafone.nl", "vodafone", "vodafone")));
       
        sendSms
(new SMS(nr, testCommunicationApn(host, port, "advancedinternet", "", "")));
        sendSms
(new SMS(nr, testCommunicationApn(host, port, "internet.maingate", "", "")));
        sendSms
(new SMS(nr, "commtest done"));
   
}


 
private String testCommunicationApn(String host, int port, String apn, String u, String p) {
       
 
String gprs = "bearer_type=gprs;access_point=" + apn + ";username=" + u
 
+ ";password=" + p + ";timeout=" + 0 + ";reverse_dns_lookup=no;";

       
SocketConnection c = null;
       
InputStream i = null;
       
OutputStream o = null;

       
try {
           
Debug.log(System.out, "ContainerManager --> APN TEST open socket to " + host + " / " + gprs);
            c
= (SocketConnection) ConnectionFactory.getSocketConnection(host, port, gprs);            
            i
= c.openDataInputStream();
            o
= c.openDataOutputStream();
            o
.write(0);
           
           
Debug.log(System.out, "ContainerManager --> APN TEST open socket OK");
       
} catch (IOException e) {
           
Debug.log(System.out, "ContainerManager --> APN TEST: " + apn + " ERROR: " + e.getMessage());
           
return apn + " Ex:" + e.getMessage();
       
} finally {
           
if (c != null) {
               
try {
                    c
.close();
               
} catch (Exception ex) {

               
}
           
}
           
if (i != null) {
               
try {
                    i
.close();
               
} catch (Exception ex) {

               
}
           
}
           
if (o != null) {
               
try {
                    o
.close();
               
} catch (Exception ex) {

               
}
           
}
       
}

       
return apn + " ok";
   
}code here...


eppie

unread,
Sep 16, 2013, 7:09:56 AM9/16/13
to java...@googlegroups.com
Even when I set the APN with AT^SJNET I do not see any difference
Reply all
Reply to author
Forward
0 new messages