Sign in to follow this  
Woody FX

Http connection

Recommended Posts

Woody FX    169
I've writen a runnable class to make a connection to a server to pass uo the highscores data etc. Pretty standard stuff. It works perfect on the emulator but on the 2 phones I've tested on its failed. The SE f500i and the Nokia 3220 and I have gprs enables etc. I have tested using sims on both the Vodafone and O2 networks. Has anybody an idea why it may be failing?

Share this post


Link to post
Share on other sites
Woody FX    169
*UPDATE*

I have checked all the GPRS settings for Vodafone and they are the recommended settings so that should be ok.

The connection has only worked once on the phones. I got the MIDlet OTA from the server and ran the game and made the connection as soon as i could and it seems to connect successfully. Then tried it again a few seconds later and it wouldnt work. So i am guessing it connected through the connection that the phone had made to get the MIDlet OTA.

Now that the phone has not made a connection the midlet has not succeded in making a connection.

Are there any Vodafone Jad attribute required for this or something?
Does the thread that makes the connection require some Thread.sleep(100); or the like to wait for a successful connection to open?

Many thanks again for your help guys.


here is how i open the connection



c = (HttpConnection)Connector.open(send_url);
c.setRequestMethod(HttpConnection.POST);
c.setRequestProperty("IF-Modified-Since", "20 Jan 2001 16:19:14 GMT");
c.setRequestProperty("User-Agent","Profile/MIDP-1.0 Configuration/CLDC-1.0");
c.setRequestProperty("Content-Language", "en-CA");
c.setRequestProperty("Content-Type","application/x-www-form-urlencoded");



int num_passes=0;
byte first=0;
byte second=0;
int third=0;
byte any_others=0;

is = c.openDataInputStream();

byte ch;
while ((ch = (byte)(is.read())) != -1)
{
b.append((char) ch);

System.out.println("Pass Num : "+num_passes);
num_passes++;

if (counter==0)
{
first=ch;
System.out.println("Byte1: "+first);
}
else if ( counter==1)
{
second=ch;
error_code = (second & 0xff) + ((first) << 8);

if (error_code == 0)
{
GameCanvas.networking_success=1;
break;
}
else
{
GameCanvas.networking_success=-1;
break;
}
}

counter++;
}




Share this post


Link to post
Share on other sites
kooktroop    176
You say it runs fine on the emulator?

I would double check, make sure you use the HTTP monitor and know exactly what is going on with the application.

Also, HttpConnection doesnt work on Nokia devices. You have to use Stream or Socket and send the HTTP commands yourself.

Share this post


Link to post
Share on other sites
Blew    358
Erm... where did you read that HttpConnection doesn't work on Nokia devices? Of course it does - as long as the device supports it (and most do).

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this