08-26-2009 03:34 AM
Hi all,
I have tried below code but i am always getting ioexception but the same url works in browser.Plz let me know what is the probolem?
StreamConnection s = null; InputStream is = null; OutputStream os = null; String msg = null; int rc; try { s = (StreamConnection)Connector.open("http://wap.xxxxx.in:8080;deviceside=true"); HttpConnection c = (HttpConnection)s; // c.setRequestMethod(HttpConnection.GET); int status = c.getResponseCode(); if (status == HttpConnection.HTTP_OK) { is = s.openInputStream(); msg =""; DataInputStream dis = new DataInputStream(is); int ch; while ((ch = dis.read()) != -1) { msg = msg + (char) ch; //deBug(msg); } if(dis!=null){ dis.close(); dis=null; } } // deBug(msg); if (is != null){ is.close(); is = null; } if (s != null){ s.close(); s= null; } }catch(SecurityException se){ msg = "-2"; // deBug("Error in SecurityException: "+se.toString()); }catch(IOException ioe){ msg = "-1"; // deBug("Error in IOException: "+ioe.toString()); }catch(Exception e){ msg = "-1"; // deBug("Error in send: "+e.toString()); }
Solved! Go to Solution.
08-26-2009 03:55 AM
Check your apn settings are correct or not.
Check HttpDemo is working or not on your device.. if it works then try HttpDemo again by replacing the default URL with your URL in it.
if httpdemo is not working , then check your apn settings with operator.
~Amardeep
08-26-2009 04:54 AM
hi amardeepjaiman,
thanks for your reply.i tried with httpdemo example too but the same exception i got it. but how could that url works in browser.(i am using airtel plan india) ?
08-26-2009 05:41 AM
Hi if you ar using airtel plan in india, check your tcp setting in advance options : it shouyld be airtelgprs.com
or just use this line in code :
String url = "http://wap.xxxxx.in:8080"+";deviceside=true;apn=airtelgprs.com";
s = (StreamConnection)Connector.open(url);
It should work now. try this
~Amardeep