Thales' cellular IoT products business is now part of Telit Cinterion, find out more.

You are here

HTTPConnection : Profile could not be activated | Telit Cinterion IoT Developer Community

April 7, 2014 - 12:52am, 8601 views

I'm executing an HTTP POST with the code below and most of the time this is working fine. private static final String CONNECTOR_EXT=";access_point=internet.proximus.be;bearer_type=gprs"; private static final String URL_PREFIX="http://my-rest-service.com/service"; private void executePOST(String url, Vector headers) throws IOException { HttpConnection httpConn = null; InputStream is = null; OutputStream os = null; try { httpConn = (HttpConnection) Connector.open(url + CONNECTOR_EXT); httpConn.setRequestMethod(HttpConnection.POST); os = httpConn.openOutputStream(); System.out.println("Response code = " + httpConn.getResponseCode()); System.out.println("Response msg = " + httpConn.getResponseMessage()); ...... On some occasions however, I'm getting the following error. (Usually the first timeI do a POST just after the board startup). java.io.IOException: Profile could not be activated - com.sun.midp.io.j2me.socket.Protocol.open(), bci=149 - com.sun.midp.io.j2me.socket.Protocol.openPrim(), bci=4 - com.sun.midp.io.j2me.http.Protocol.createConnection(), bci=31 - com.sun.midp.io.j2me.http.Protocol.connect(), bci=41 - com.sun.midp.io.j2me.http.Protocol.streamConnect(), bci=108 - com.sun.midp.io.j2me.http.Protocol.startRequest(), bci=7 - com.sun.midp.io.j2me.http.Protocol.sendRequest(), bci=33 - com.sun.midp.io.j2me.http.Protocol.sendRequest(), bci=3 - com.sun.midp.io.j2me.http.Protocol.openInputStream(), bci=6 - com.ecs.hello.HelloWorld.downloadPage(HelloWorld.java:73) - com.ecs.hello.HelloWorld.startApp(HelloWorld.java:46) - javax.microedition.midlet.MIDletTunnelImpl.callStartApp(), bci=1 - com.sun.midp.midlet.MIDletPeer.startApp(), bci=5 - com.sun.midp.midlet.MIDletStateHandler.startSuite(), bci=261 - com.sun.midp.main.AbstractMIDletSuiteLoader.startSuite(), bci=38 - com.sun.midp.main.CldcMIDletSuiteLoader.startSuite(), bci=5 - com.sun.midp.main.AbstractMIDletSuiteLoader.runMIDletSuite(), bci=134 - com.sun.midp.main.AppIsolateMIDletSuiteLoader.main(), bci=26 Can this occur because the modem hasn't established a valid connection yet ? (waiting for a signal, connecting to the provider ?). I have a midlet that, upon startup, executes 3 POSTs with a 10 second interval and 95% of the time the first POST never occurs. I don't have logging at this point but I assume it is the error above. How should my code handle this scenario ? Is there a clean way for me check if connectivity is available before attempting to do a POST ?