saulpower / Android-Faye-Client

A Faye client for Android
53 stars 22 forks source link

trying to avoid exception error when Internet connection drops #3

Open sallespro opened 10 years ago

sallespro commented 10 years ago

hi, i am successfully using this lib, but there's one "corner" i could not figure out how to deal with.

when we switch off WiFi for instance, the app crashes because of this unhandled exception.

 java.net.SocketException: recvfrom failed: ETIMEDOUT (Connection timed out)
            at libcore.io.IoBridge.maybeThrowAfterRecvfrom(IoBridge.java:545)
            at libcore.io.IoBridge.recvfrom(IoBridge.java:509)
            at java.net.PlainSocketImpl.read(PlainSocketImpl.java:488)
            at java.net.PlainSocketImpl.access$000(PlainSocketImpl.java:46)
            at java.net.PlainSocketImpl$PlainSocketInputStream.read(PlainSocketImpl.java:240)
            at libcore.io.Streams.readSingleByte(Streams.java:41)
            at java.net.PlainSocketImpl$PlainSocketInputStream.read(PlainSocketImpl.java:236)
            at java.io.DataInputStream.readByte(DataInputStream.java:75)
            at com.saulpower.fayeclient.HybiParser.start(HybiParser.java:120)
            at com.saulpower.fayeclient.WebSocketClient$1.run(WebSocketClient.java:155)
            at java.lang.Thread.run(Thread.java:841)
     Caused by: libcore.io.ErrnoException: recvfrom failed: ETIMEDOUT (Connection timed out)