SE T6xx GPRS connection problems
I'm developing a game that uses HttpConnection. I test it on T630. On the emulator everything is fine, but on the device I get IOException.
I saw a lot of topics about this problem but no solution yet. My GPRS settings are ok since Opera Mini browser works fine and it uses HttpConnection too.
I have exception on httpConnection.openInputStream() (see the code below).
An example from SDK doesn't work on the phoe too.
Please help or maybe give me a working HttpConnection example for T6xx.
private void connect()
{
DataOutputStream out = null;
InputStream in = null;
byte [] buffer = null;
int outLen = outBuff.pos;
try
{
httpConnection = (HttpConnection)Connector.open(serverURL, Connector.READ_WRITE, false);
httpConnection.setRequestMethod(httpConnection.POST);
httpConnection.setRequestProperty("Connection", "close");
httpConnection.setRequestProperty("Content-Length", ""+outLen);
httpConnection.setRequestProperty("Content-Type", "image/jpeg");
if( mSession != null )
{
httpConnection.setRequestProperty("Cookie", mSession);
}
out = httpConnection.openDataOutputStream();
byte [] sendMe = outBuff.data;
for (int i = 0; i < sendMe.length; i++){
out.writeByte(sendMe[ i ]);
}
out.close();
out = null;
in = httpConnection.openInputStream(); // IOException here!
String cookie = httpConnection.getHeaderField("Set-cookie");
if (cookie != null) {
int semicolon = cookie.indexOf(';');
mSession = cookie.substring(0, semicolon);
}
int inInt;
byte inByte;
int inLen = 0;
buffer = inBuff.data;
while( (inInt = in.read())!=-1 )
{
inByte = (byte)inInt;
buffer[ inLen ] = inByte;
inLen++;
}
in.close();
in = null;
httpConnection.close();
httpConnection = null;
if( !cancelConnect ){ Game.instance.networkResponseFlag = true; }
}
catch (Exception ioe)
{
try
{
if (out != null){
out.close();
out = null;
}
if (in != null){
in.close();
in = null;
}
if (httpConnection != null){
httpConnection.close();
httpConnection=null;
}
}
catch (Exception e) {};
}
finally
{
if( !safeCancel )
{
Game.instance.gameEnd = true;
Game.instance.showMessage( FONTconst.MSG_CONNECTION_FAILED, Constants.ST_NEWMENU );
}
cancelConnect = false;
safeCancel = false;
isDoConnection = false;
}
}//connect
[2673 byte] By [
xdimasa] at [2007-10-3 3:52:36]

try this:
suppress these lines
out.close();
out = null;
and put these lines
out.flush();
if (httpConnection.getResponseCode() != HttpConnection.HTTP_OK){
throw new IOException("HTTP response code: " + httpConnection.getResponseCode() );
}
The HttpConnection class from the API docs has a nice working example on how to send and receive data. Don't forget that you have to write at the end of your data a "\r\n". Calling flush() is optional because getResponseCode() will flush automatically.Mihai
> try this:
> suppress these lines
> > out.close();
> out = null;
>
> and put these lines
> > out.flush();
> if (httpConnection.getResponseCode() !=
> HttpConnection.HTTP_OK){
> throw new IOException("HTTP response code: " +
> httpConnection.getResponseCode() );
> }
>
If I do so I get IOException on flush();
> The HttpConnection class from the API docs has a nice
> working example on how to send and receive data.
This code is actually based on that sample and it works ok on a bunch of phones but not on SET630.
> Don't forget that you have to write at the end of
> your data a "\r\n". Calling flush() is optional
> because getResponseCode() will flush automatically.
I've tried to put "\r\n" but it didn't help.
comment these lines out.close(); out = null;and close the out stream before the in stream after processing
If you say that your code is based on the example from the API, you should have noticed that the streams are closed at the end, when the writing and reading is done. Also, can you bee more specific on the IOException you get?Mihai
Beside being more specific on the IOException which you get, also what do you get if you don't put a flush, but leave the is statement? What is the response code that you get from the server? Also, when you write first, does the server get the data you sent?Mihai
Well.
If I don't use flush() I get IOException on openInputStream(). If I try to getResponceCode() I get IOException too.
Seems like it throws exception in the moment then the data starts to be sending over GPRS (flushing).
On the phone then I try to connect I see the GPRS globe then it asks me for connection permittion. I allow it and after a little time I get IOException.
Sever recievs no data.
Try opening the URL to your server from a browser different than Opera MiniBrowser (phone's default browser) and tell us if it works.Mihai
Yes you should try from browser firstwhat's the url is it accessible from browser on mobile?and what's the exact exception you getting?
The server is accessible - I've tried it.The exception is IOException
seems you don't have full network accessask your providers about whether u r able to acess it fully?or you may have some other problemcan you acess any site from j2me?
In the main menu go to connectivity then Data comm then Data accounts then select
New account
select Gprs data
the entry should be like this .
Name = www
APN=www
then save
then come back to connectivity
then wap option then wap profile then New profile press Add
then Name =www
for field : Connect using select "www"
ip adress =0.0.0.0
save
then go to connectivity select Wap option then select wap profile then select "www" as the Wap profile
Then come back to the application and run it
> seems you don't have full network access
> ask your providers about whether u r able to acess it
> fully?
>
> or you may have some other problem
> can you acess any site from j2me?
I don't think so since this app works fine on a bunch of phones including SE K300, SE K500 SE K700 etc
> In the main menu go to connectivity then Data comm
> then Data accounts then select
> New account
> select Gprs data
> the entry should be like this .
> Name = www
> APN=www
> then save
> then come back to connectivity
> then wap option then wap profile then New profile
> press Add
> then Name =www
> for field : Connect using select "www"
> ip adress =0.0.0.0
> save
> then go to connectivity select Wap option then select
> wap profile then select "www" as the Wap profile
> Then come back to the application and run it
I see no sence in doing this. Note that Opera mini works fine with my current GRPS settings. Opera mini is the J2Me application that uses HttpConnection so I think there is some error in my code not in settings
did you got any specific error code
NoIf I try to getResponceCode() I have IOException too
Just put httpConnection.getResponceCode() before httpConnection.openInputStream() or before out.close() in the code posted above (I tryed both)
>>My GPRS settings are ok since Opera Mini browser works fine and it uses >>HttpConnection too.
no that's not true
even i can acess opera but not from my application
i wonder because it was working fine before
and suddenly it stopped the guys in customer care have no answer
Your code is fineproblem is with simcard or phonecan you replace the sime to other phone and check ur application there ?
I've tried this SIM on other phones and a different SIM on SET630 - on other phones all is OK, on SET630 it never works %(
>>on SET630 it never works for all phones of type SET630 it never works or for that phone only?
SET 630 and SET 610: two phones, the same result
Hello i have also been testing, on a Nokia N series, Sony Ericsson, and a samsung. I get an IOexcpetion when the phones try to execute the HttpConnection.openInputStream()code. The samsunng and the sony the nokias just crushMessage was edited by: princ
princa at 2007-7-21 10:19:35 >
