• Post Reply Bookmark Topic Watch Topic
  • New Topic

Need help in HttpConnection  RSS feed

 
Mirai Chelean
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all, i have a problem in HttpConnection.

The case is like this:
Using the same coding (MIDlet) and the exatcly same server application on different servers. Why i can connect one of them but can't on the other one? Anyone faced this problem before and can share with the experience?

Many thanks in advance.

Best & regards.
 
Mark Spritzler
ranger
Sheriff
Posts: 17309
11
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does you other server have a different IP Address or different URL? Your code, or actually better your jad file has the URL/IP in it "hard coded" So unless you changed it, then you are still having your MIDlet point to the original server.

Mark
 
Mirai Chelean
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi mark,

Thanks for replying me. Ok, maybe i'm still very new to MIDlet/J2ME. But can you or any volunteers to give a try to my server http://www.bettaking.com and see whether you guys having the same problem like me? I have tries so many times and many ways yet still can't figure out whats wrong with it.

Here is my simple code to get the return response status code:

try {
conn=(HttpConnection)Connector.open(requested,Connector.READ_WRITE);
is=conn.openInputStream();
int respondCode=conn.getResponseCode();
String status=Integer.toString(respondCode);
response.setText(status);
form.append(response);

is.close();
conn.close();
}
catch (IOException ioex) {
Alert a=new Alert("Error",ioex.toString(),null,AlertType.ALARM);
a.setTimeout(Alert.FOREVER);
display.setCurrent(a);
}

Using that codes i get an exception error. But the same coding working on other websites like http://www.yahoo.com/ or other valid url. At least it will return the response code indicated success or not. But not with my website. http://www.bettaking.com

Thank you all for your concern and helps.

Regard,
Mirai
 
Debojit Nag
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
First u should make this clear whether u r getting an exception or an error. Guessing for an exception, I think the server may not have the WRITE permission. So try it out with READ mode only! Also with the timeout option!

Connector.open(url, Connector.READ , false);

Debojit
 
Mirai Chelean
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you debojit , but that yet didn't fix the problem after i'd change as showing.

I think there is nothing wrong with the coding since i find out many reference also using that style to read from http. It most probably is something doing with the web server.

My project has been stuck since i can't find any clue to solve that problem.

Mirai
 
Mirai Chelean
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmm, i manage to find some clues. The ioexception occur when i trying to establish an openInputStream.



IOException is only thrown if there is a clear indication from the network (i.e. Connection refused/Host unreachable) that the server isn't listening/unreachable. If the TCP connection attempt goes completely unanswered (e.g. due to a DROP in a firewall) openInputStream will keep hanging until it times out.


The conclusion is, I'm still not manage to figure out what happened and why it just happened to my web server.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!