• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Help with the HttpConnection when it is blocked

 
Armando Miranda
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I getting troubles with a HttpConnection. I have an application that needs to transmit data to our server. Well I got it but the problem comes when I simulate a zone with less coverage than normal I mean a zone where you can find a little signal to trasmit data, and start to send this information and immediatly go a place where the coverage is null in the middle of the transmision. That situation provokes my application got frezze.
At the beggining I was using this line of code:
conexion = (HttpConnection)Connector.open(url);

But I saw this class can use another methods like the mode I'm going to use and the expitarion time. After that I change the last line for this one:

conexion = (HttpConnection)Connector.open(url, Connector.READ_WRITE, true);
Where I use the expitarion time just to know if after some time the server does not respond anything, but at the moment entering on the environment I mentioned the application got freeze and I don't know what exactly is happening.

When the application runs into an envinronment with out coverage it respoondes with alerts that indicates the fail in the transmission and on the environment with full coverage too.

Do you have any idea how can I resolve this problem ???
I would be grateful with your Help.

Thanks

Armando M.
 
Arun Soman
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As my understanding goes, ur connection goes to a hung state when u go out of coverage area. that could be because u might be using some thing like
while(connection.read()){
doSomeThing..
}
or a variant of this.

If this is the case what u could do is run a timer for the timeout period which sets the variable timeOut = true. And then you could use some thing like this

int readBytes = 0;
while(timeOut != true){
while((readBytes = connection.available()) > 0 ){
connection.read(data, currIndex, readBytes);
}
}

best of lucks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic