problem with connection | Telit Cinterion IoT Developer Community
July 15, 2019 - 9:13pm, 9489 views
Hello good afternoon.
I am trying to establish a Https GET connection, with a midlet in java.
I get an exception in httpConn.getResponseCode ();
What I want is to know if I have to configure something with the at commands.
AT ^ SICS = 0, "conType", "gprs0"
at ^ siss = 0, srvType, http
?
and I want to know if there is any way to know that I have an internet connection, and that the apn I enter is valid.
Hello,
You don't have to use AT commands when using Java MIDlet. Every needed paraemter (APN name, bearer type, etc.) you can provide in connection string. You can also provide those parameters using AT^SJNET commands.
Could you please let me know what exception you got? It should narrow the issue down.
To check if you have internet connection, please use AT^SMONI command. I think, the simplest test to check if your APN is valid is also by using AT commad: set APN in AT+CGDCONT, try to activate it by sending CGACT command and check if you have IP by sending CGPADDR command.
Please let me know if something is unclear, I will try to provide logs.
What module do you use? Can you provide ATI1 command to check FW version?
Thanks,
Adam
Good afternoon, thank you very much for your help.
The commands have been useful to me, the connection is perfect. So, that is not the problem.
The exception is the following: "java.io.IOException: Profile could not be activated"
-----------------------------------------------
ATI1
Cinterion
EHS6
REVISION 03.001
A-REVISION 00.000.51
-------------------------------------------------
java code:
30 HttpConnection httpConn = null;
31 httpConn = (HttpConnection)Connector.open(url+";bearer_type = gprs; access_point = internet; username =; password =");
32 httpConn.setRequestMethod(HttpConnection.GET);
33 httpConn.setRequestProperty("User-Agent","Profile/MIDP-2.0 Configuration/CLDC-1.0");
34 httpConn.setRequestProperty("Content-Language","es-ES");
35 int responseCode = httpConn.getResponseCode(); //(exception)
-----------------------------------------------------------
I changed line 31 to: httpConn = (HttpConnection)Connector.open(url);
I have removed line 34
I have removed line 33
I have tried different ways, and all give the same exception
I forgot it.
I have tried with different URLS, same error.
and I have tried the URLS in another code in JAVA and not in J2ME and in JAVA it works correctly.
so the http server is not the problem either
at+CGPADDR
+CGPADDR: 1,"10.47.177.185"
AT^SMONI
^SMONI: 3G,3011,452,-8.0,-72,214,07,099D,1A87C81,10,43,NOCONN
OK
I get ip, but when I execute this command not
at^sici?
^SICI: 1,0,0,"0.0.0.0"
can this problem be?
I tried to do it from at commands, and it gave me this result:
AT^SISS=3,srvType,"Http"
OK
---- 16/07/2019 20:59:55
AT^SISS=3,conId,"1"
OK
---- 16/07/2019 21:00:21
AT^SISS=3,address,"https://*******************"
OK
---- 16/07/2019 21:00:31
AT^SISS=3,cmd,"get"
OK
---- 16/07/2019 21:00:40
AT^SISO=3
OK
^SIS: 3,0,2200,"Http *********:***"
^SIS: 3,0,94,"PDP: connection failed"
I deleted the http address because I can not show it
-------------------------------------------
with another url, which is public
---- 16/07/2019 21:05:25
AT^SISS=2,srvType,"Http"
OK
---- 16/07/2019 21:05:36
AT^SISS=2,conId,"1"
OK
---- 16/07/2019 21:06:13
AT^SISS=2,address,"https://jsonplaceholder.typicode.com/todos/1"
OK
---- 16/07/2019 21:06:23
AT^SISS=2,cmd,"get"
OK
---- 16/07/2019 21:06:38
AT^SISO=2
OK
^SIS: 2,0,2200,"Http jsonplaceholder.typicode.com:443"
^SIS: 2,0,210,"INT:DNS Invalid"
I leave these answers:
at^sici?
^SICI: 1,0,0,"0.0.0.0"
at + cgreg?
+ CGREG: 0.1
OK
Apparently it is a problem of connection to Internet, that I do not configure it well.
Hello,
thanks for all your feedback. I think, firstly we should focus on making it working using AT commands.
Regarding CGDCONT command, I suggested it only for testing purpose, to check if APN that you use is ok. But, If you want to use IP services by AT commands, you have to use AT^SICS command to configure APN. I'm sorry if my previous comment was confusing.
Could you please follow commands from log below?
at^scfg="tcp/withurcs","on" //enable URCs during IP service
^SCFG: "Tcp/WithURCs","on"
OK
at^sics=2,contype,GPRS0 //configure bearer type on SICS profile 2
OK
at^sics=2,apn,internet //configure APN name on SICS profile 2
OK
AT^SISS=1,srvType,"http" //set siss profile 1 to http
OK
AT^SISS=1,conId,2 //connect siss profile 1 with sics profile 2
OK
AT^SISS=1,cmd,get //set siss profile 1 to http get method
OK
AT^SISS=1,address,https://httpbin.org/get //set the url on siss profile 1
OK
at^siso=1 //open siss profile 1
OK
^SIS: 1,0,2200,"Http httpbin.org:443"
^SISR: 1,1
at^sisr=1,1500 //get data
^SISR: 1,302
{
"args": {},
"headers": {
"Accept": "*/*",
"Content-Type": "application/x-www-form-urlencoded",
"Host": "httpbin.org",
"User-Agent": "Profile/MIDP-2.0 Configuration/CLDC-1.0 UNTRUSTED/1.0"
},
"origin": "77.112.18.247, 77.112.18.247",
"url": "https://httpbin.org/get"
}
OK
^SISR: 1,2
Best regards,
Adam
thank you very much Adam.
I have tried what you have sent me and it worked correctly. there is only one problem:
If I restart the module it does not work anymore, I have to restart it without the sim card, and then put it back on and restart it and it works again.
Then how do I do the same request again without restarting the module?
I tried then with the other servers https, and they do not connect me either.
I leave my tests:
--------------------------------------------------------------
at^scfg="tcp/withurcs","on"
^SCFG: "Tcp/WithURCs","on"
OK
at^sics=2,contype,GPRS0
OK
at^sics=2,apn,"m2m.movistar.es"
OK
AT^SISS=1,srvType,"http"
OK
AT^SISS=1,conId,2
OK
AT^SISS=1,cmd,get
OK
AT^SISS=1,address,https://httpbin.org/get
OK
at^siso=1
OK
^SIS: 1,0,2200,"Http httpbin.org:443"
^SISR: 1,1
at^sisr=1,1500
^SISR: 1,307
{
"args": {},
"headers": {
"Accept": "*/*",
"Content-Type": "application/x-www-form-urlencoded",
"Host": "httpbin.org",
"User-Agent": "EHS6/359804081806418 Profile/IMP-NG Configuration/CLDC-1.1"
},
"origin": "176.83.141.31, 176.83.141.31",
"url": "https://httpbin.org/get"
}
OK
^SISR: 1,2
------------------------------------------------------------------------
at^scfg="tcp/withurcs","on"
^SCFG: "Tcp/WithURCs","on"
OK
at^sics=2,contype,GPRS0
................(Here would go the rest of the AT Comand)
AT^SISS=1,address,https://jsonplaceholder.typicode.com/todos/1
OK
at^siso=1
OK
^SIS: 1,0,2200,"Http jsonplaceholder.typicode.com:443"
^SIS: 1,0,210,"INT:;IOError -149 during socket:: write \0a"
--------------------------------------------------------------------------
at^scfg="tcp/withurcs","on"
^SCFG: "Tcp/WithURCs","on"
OK
............. (Here would go the rest of the AT Comand)
AT^SISS=1,address,https://***************xxxxxx
OK
at^siso=1
OK
^SIS: 1,0,2200,"Http ***************:443"
^SIS: 1,0,210,"INT:DNS Invalid"
Hello,
Could you please provide logs how module behaves during connection with httpbin.org server after module reboot with SIM card inserted?
Regarding https://jsonplaceholder.typicode.com/todos/1, could you please for testing purpose check the same server but without TLS (http://jsonplaceholder.typicode.com/todos/1)?
About last log, I can see error ^SIS: 1,0,210,"INT:DNS Invalid". Would it be possible for you to try to connect to this server using IP address instead of domain name?
Thanks,
Adam
AT^SISS=1,address,http://jsonplaceholder.typicode.com/todos/1
OK
at^siso=1
OK
^SIS: 1,0,2200,"Http jsonplaceholder.typicode.com:80"
^SIS: 1,0,200,"DNS Invalid"
------------------------------------------------------------------------------
When I restart the module without removing the Sim card, this line never returns it to me:
^SISR: 1,1
and when executing the next one I get an error
Sometimes if I wait, it comes to appear, but I have to wait in 1 minute and it returns that line. and if it would work.
But it rarely appears. Even sometimes I have to wait up to 5 minutes for me to return this line. and it is not always correct, these 3 options can appear:
^SISR: 1,1
^SIS: 1,0,3,"Bad address specified"
^SIS: 1,0,210,"INT:DNS Invalid"
---------------------------------------------------------------------------------
AT^SISS=1,address,https://httpbin.org/get
OK
at^siso=1
OK
^SIS: 1,0,2200,"Http httpbin.org:443"
^SIS: 1,0,3,"Bad address specified"
at^sisr=1,1500
+CME ERROR: operation not allowed
---------------------------------------------------------------------------------------
AT^SISS=1,address,https://httpbin.org/get
OK
at^siso=1
OK
^SIS: 1,0,2200,"Http httpbin.org:443"
^SIS: 1,0,210,"INT:DNS Invalid"
it seems to me that restarting without the Sim card has been a coincidence. Sometimes it works and sometimes it does not. but most of the time, it does not work.
I changed the dns and it worked for with the public server.
at^siso=1
OK
^SIS: 1,0,2200,"Http jsonplaceholder.typicode.com:80"
^SISR: 1,1
at^sisr=1,1500
^SISR: 1,83
{
"userId": 1,
"id": 1,
"title": "delectus aut autem",
"completed": false
}
OK
^SISR: 1,2
but it happens the same as with the previous one(https://httpbin.org/get), some***** it works but most ***** it does not work. and the same 3 messages can be output.
^SISR: 1,1
^SIS: 1,0,3,"Bad address specified"
^SIS: 1,0,210,"INT:DNS Invalid"
Including one more than in the previous one so far has not shown me.
^SIS: 1,0,210,"INT:;IOError -149 during socket:: write \0a"
this last one has appeared with this server and with which I have to use that I can not give.
Pages