RC33 Network Problem

by Gil » Tue, 17 Feb 2009 06:29:26 GMT


Sponsored Links
 I finally got to test some code on the RC33 release and I uncovered a
difference in the network code compared to earlier versions and the
emulator. I'm using a persistent TLS connection to a server and a
BufferedInputStream to read from the socket. The problem is that the
read method throws an IOException only 5 minutes after the Wi-Fi
connection looses connectivity (I unplug the Internet connection from
the router to simulate a connection problem). In RC30 and earlier
version as well as the latest emulator version (SDK 1.1) read throws
an exception after approximately 30 seconds after the connectivity is
lost. My code uses an infinite timeout for read (setSoTimeout(0)).

--~--~---------~--~----~------------~-------~--~----~



RC33 Network Problem

by Marc » Tue, 17 Feb 2009 08:23:04 GMT


 I've seen inconsistent behavior from RC30 on in this regard.  The
IOException happens anywhere from instantly to five minutes later.  It
seems like a bug to me.

Marc



--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


RC33 Network Problem

by Guillaume Perrot » Tue, 17 Feb 2009 23:21:58 GMT


 I had the same problem too.
Plus when I loose connectivity, it's nearly impossible not to block on
socket.close();
It takes forever in that case.
I tried both plain and ssl sockets, same behavior in RC33.




--~--~---------~--~----~------------~-------~--~----~



RC33 Network Problem

by Gil » Wed, 18 Feb 2009 01:51:47 GMT


 What is disturbing is that event if you try to send data on a socket
that is not actually connected (according to the situation I outlined
initially) the socket does not throw an IOException. It simply thinks
it is still connected.





--~--~---------~--~----~------------~-------~--~----~



RC33 Network Problem

by Guillaume Perrot » Wed, 18 Feb 2009 02:06:19 GMT


 Yes it's exactly what happens since RC33.
Kinda annoying. I have to close sockets in a separate thread when I
receive a connectivity event indicating the network is down or we
switched network. This thread becomes zombie most of the time because
the socket refuses to close (deadlock with a nativeread).

2009/2/17 Gil <virgildobjans...@gmail.com>:






-- 
Guillaume Perrot
Software Engineer at Ubikod
BuddyMob developer

--~--~---------~--~----~------------~-------~--~----~



RC33 Network Problem

by Gil » Wed, 18 Feb 2009 03:19:30 GMT


 Unfortunately, watching the network state will not always work because
it does not account for end-to-end TCP connectivity. The server may
crash or its Internet connection may go down and you won't know about
it.

On Feb 17, 10:05am, Guillaume Perrot <guillaume.p...@gmail.com>





--~--~---------~--~----~------------~-------~--~----~



RC33 Network Problem

by Gil » Wed, 18 Feb 2009 03:43:03 GMT


  did further testing and I was wrong about one thing: the disconnect
is not detected at all (not even after 5 minutes as I said initially).
The reason I though that the disconnection was detected after 5 min.
is because the W-Fi was going to sleep. If I keep Wi-Fi alive by not
allowing the phone to go to sleep the problem is quite evident. I also
looked at the GTalk debug messages and it turns out that it has the
same problem (it never detects that it is disconnected from the
server).

On Feb 17, 11:19am, Gil <virgildobjans...@gmail.com> wrote:
--~--~---------~--~----~------------~-------~--~----~



RC33 Network Problem

by Gil » Wed, 18 Feb 2009 09:02:22 GMT


 an anyone from Google comment on this matter?

On Feb 17, 11:42am, Gil <virgildobjans...@gmail.com> wrote:
--~--~---------~--~----~------------~-------~--~----~



RC33 Network Problem

by Justin (Google Employee) » Thu, 19 Feb 2009 09:28:47 GMT


 'm looking into this further, although I'm not sure that this is
actually wrong behavior. In terms of the network interface, there is
no change when the router loses internet connectivity. The phone is
still connected to the router. The only way anything can really deal
with this is to have a timeout. If no response is sent in X seconds,
assume the remote server died or there is no path to it. While
inconvenient, you should be able to extend BufferedInputReader to use
this timeout mechanism. Have a timer thread, that if the timer expires
and no bytes have been read, throw an exception.

I'll look into this further.

Cheers,
Justin
Android Team @ Google

On Feb 17, 5:02pm, Gil <virgildobjans...@gmail.com> wrote:
--~--~---------~--~----~------------~-------~--~----~



RC33 Network Problem

by Gil » Thu, 19 Feb 2009 09:52:17 GMT


 es, the phone still has the connection to the router however what
matters is the status of the TCP socket which needs end-to-end
connectivity. Applications need to know when TCP connectivity is lost.

Not all TCP based protocols require a response for a request. For
example in XMPP you send keep-alive packets to the server the server
does not actually respond. Also, sending packets just to see if the
TCP connection is alive is a waste of battery power.

It is wrong for a disconnected socket not to throw an IOException when
trying to send data as well as when executing a blocking read. It also
needs to throw and EOFException when the server disconnects. While
this behavior is not in the documentation one would expect the same
API behavior in dalvik and JVM from this standpoint. I want to
reiterate that prior firmware versions (RC28/maybe RC30 and earlier)
exhibited the correct behavior from this standpoint. Even the current
emulator works fine by throwing an IOException from a blocking read 20
to 30 seconds after the TCP connection is lost.

On Feb 18, 5:28pm, "Justin (Google Employee)" <j...@google.com>
wrote:
--~--~---------~--~----~------------~-------~--~----~



RC33 Network Problem

by Guillaume Perrot » Tue, 14 Apr 2009 17:49:39 GMT


 eah, the behavior definitely changed in RC33, I am still having
difficulties to close a socket while the 3G connectivity has been
lost.

On 19 fv, 03:52, Gil <virgildobjans...@gmail.com> wrote:
--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. Center Text in a AlertDialog.Builder

Hi

how do I have to change my AlertDialogBuilder to center the Items?

return new AlertDialog.Builder(preferences.this).setTitle("my titel")
  .setItems(daysList, new DialogInterface.OnClickListener() {
      public void onClick(DialogInterface dialog, int which) {
                dbHelper.SetStartWeek(""+which);
}}).create();

Thanks
Chris

--~--~---------~--~----~------------~-------~--~----~

2. aapt error with Standard menu icons (resource is not public)

Hello

I've been trying to include standard android icons in a menu XML file,
as described in Android Icon design guidelines. However the build
fails with the following errors :

[2009-06-04 00:00:31 - Laser] W/ResourceType(16578): Bad XML block:
header size 2475 or total size 0 is larger than data size 0
[2009-06-04 00:00:31 - Laser] /home/niko/dev/workspace/Laser/res/menu/
main.xml:4: ERROR Error: Resource is not public. (at 'icon' with value
'@android:drawable/ic_menu_play_clip').
[2009-06-04 00:00:31 - Laser] Unknown error:

The only threads I could find with this error were about rebuilding
android platform xml files. Any idea about what I could have missed ?

--~--~---------~--~----~------------~-------~--~----~

3. Excluding test files from the compiled Android app

4. Overlay Interface

5. ACTION_PHONE_STATE_CHANGED working in 1.5 SDK?

6. Detecting hardware capabilities

7. update gui from a separate thread