02-22-2011 03:49 AM
Hi,
My midlet work fine in 9700, 9300, 8320 but today we tryed the 9800 torch and we got an error trying to connect to internet with HttpConnection.
We tryed to configure manually the apn but don't work.
Something change on this model? Need to change the code for etablish connection?
Here is the code :
[CODE]
[/CODE]
But this code create an exception ...
Thanks
02-22-2011 03:54 AM
and the exception would be? crystall ball all cloudy ![]()
depending on the connection type of the device you may have to use a connection suffix to connect. check the sticky thread about it or use peters sample code.
02-22-2011 04:44 AM - last edited on 02-22-2011 04:45 AM
I think there is a potential bug in your code too:
You say the data is URL encoded with this:
http.setRequestProperty("CONTENT-TYPE", "application/x-www-form-urlencoded");
But you set the length to this:
02-22-2011 06:45 AM
Hi,
Thanks for the advice peter.
I fixed it i think now i do :
http.setRequestProperty("Content-Length", Integer.toString(rawData.getBytes().length));But the problem with the 9800 still.
I try to read your post but my english it's too bad for unterstand all.
Maybe i need to play with the deviceside and add this code no?
;deviceside=true
Thanks
02-22-2011 07:16 AM
re-read peters post, you did not change your code correctly.
02-22-2011 07:50 AM
Hi simon_hain
Peter says :
So always get your data in byte form before you determine its length.
So i changed the line :
http.setRequestProperty("Content-Length", Integer.toString(rawData.length()));
for :
http.setRequestProperty("Content-Length", Integer.toString(rawData.getBytes().length));
I think that is good.
02-22-2011 07:52 AM
Let us just make certain we all know what is going on here.
As SImon says, your code change may not be accurate. Here is the code from the sample connection I posted here:
I have removed redundant lines
byte [] postBytes = _postParameters.getBytes();
_httpConnection.setRequestProperty(HttpProtocolCon
os = _httpConnection.openOutputStream();
os.write(postBytes);
os.flush();
os.close();
os = null;
So I get the bytes in byte [] form, ready to write, before I calculate the length.
That said, I think when you say:
"I try to read your post but my english it's too bad for unterstand all."
You are either talking about the post mentioned above or this long one:
I'm sorry that your English is not up to reading what I have written. I sympathize. My French/German/Spanish/<insert language of choice> is not good enough to even get as far as you have!
However I do try to write as clearly as I can knowing non English speakers read this forum. So I'm not sure that I can explain anything more clearly.
I would recommend that you review the second Thread I mentioned above, especially the "Required Reading" which is mainly RIM stuff. Hopefully it is clearer than what I wrote.
Finally we must get back to the point of this Thread. You said:
"But this code create an exception ..."
Simon said:
"and the exception would be?"
Can we have the answer to Simon's question please. It will help us understand the problem you are having.
I strongly suspect that you are managing to use default connection methods in the phones you have tested, and that the Torch does not have one. So in fact, your connection on the other devices was more by accident than by design, and you need to confirm exactly what your connection method is to make sure that you know what you should be looking for.
To help with this, you could use the Network Diagnostics:
or use the code that I supplied in the first post I mentioned. I suggest my code because it logs everything that it does, so you can find out your problems quicker. But the network diagnostics is a much more complete test.
Anyway, lots for you to look at, sorry this is not easy, good luck and come back to us when you need more or you can tell us what the Exception was.
02-22-2011 10:16 AM
Hi,
The exception message is : Tunel failed.
Best Regards
02-22-2011 10:28 AM - last edited on 02-22-2011 10:29 AM
This suggests you have not coded the appropriate APN values (and user and password perhaps) in the Options. This should be explained in a number of places, including this KB article:
02-22-2011 11:29 AM
Hi peter,
The apn are configurated on the blackberry and i also try with :
http = (HttpConnection) Connector.open(url + "";deviceside=true;apn=movistar.es;tunnelauthusern
and get tunel failed
and with
http = (HttpConnection) Connector.open(url + "";deviceside=false");
Invalid url parameter.
Best regards