autofocus / asmack

Automatically exported from code.google.com/p/asmack
Other
0 stars 0 forks source link

Client does not detect when socket to server is broken #16

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What are you doing to produce the error?
1. Open a connection with a server
2. Kill the server without giving it chance to close the socket neatly, or, 
break the connection between the client and server (for example, by 
removing network cable connecting server to wifi router)
3.

What is the expected output?

I would expect that the client detects the socket is gone the next time it 
sends a keep alive or packet to the socket. However, the writer.flush() 
method on line 195 and 295 of PacketWriter.java does not generate an 
exception and so the mechanism for tearing down the connection is not 
triggered. I don't know if this is correct behavior of the Java 
BufferedWriter class or not (suspect it isn't and flush() should throw an 
exception).

What do you see instead? (Please attach a debug enabled logcat)

Connection stays open and I can continue to write packets to the connection 
without knowing it has gone.

What version of aSmack / Android / Device do you use?

2010.05.07
Android 2.1 on Nexus One

What server do you use? Is there a public server to reproduce the problem?

It is a custom server.

What else might help us to reproduce and hunt down the problem?

Original issue reported on code.google.com by alfred.o...@gmail.com on 14 May 2010 at 5:31

GoogleCodeExporter commented 9 years ago
flush() and write in general are broken on many many phones. Motorola Milestone 
is
one of the best examples of a phone that can go into flight mode without 
throwing an
exception.

Did you try this via wifi or via gsm?

You should try to detected stalled methods on your own, e.g. with xmpp ping (you
*will* get a reply, error or success). This is usually more stable than a naive
solution, especially as your GSM may lie.

Original comment by rtreffer@gmail.com on 14 May 2010 at 6:11

GoogleCodeExporter commented 9 years ago
I have done the next test:

- start openfire
- start client
- shutdown and start openfire
- send packet from client

And I get:
 connectionClosedOnError
 java.io.IOException: Write error: I/O error during system call, Broken pipe
     at org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl.nativewrite(Native
Method)
     at
org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl.access$600(OpenSSLSocket
Impl.java:54)
     at
org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl$SSLOutputStream.write(Op
enSSLSocketImpl.java:568)
     at java.io.OutputStreamWriter.flush(OutputStreamWriter.java:183)
     at java.io.OutputStreamWriter.convert(OutputStreamWriter.java:263)
     at java.io.OutputStreamWriter.write(OutputStreamWriter.java:252)
     at java.io.BufferedWriter.flush(BufferedWriter.java:145)
     at org.jivesoftware.smack.util.ObservableWriter.flush(ObservableWriter.java:48)
     at org.jivesoftware.smack.PacketWriter.writePackets(PacketWriter.java:195)
     at org.jivesoftware.smack.PacketWriter.access$000(PacketWriter.java:42)
     at org.jivesoftware.smack.PacketWriter$1.run(PacketWriter.java:78)

So, at this moment asmack knows that the connection is broken and it is still 
not
reconnecting. I think that in this error the asmack could recover from crash 
starting
the reconnecting.

Im sorry if I haven't understood well but I hope this will help.

I have used asmack-2010.05.07.jar

Original comment by cver...@gmail.com on 1 Jun 2010 at 3:16

GoogleCodeExporter commented 9 years ago
I see a related issue on nexus one 2.1

Migrate from wifi to edge, you get a connection closed on error, then reconnect 
the existing xmpp connection. All looks fine, but when you send a packet it is 
never sent, without any error

Original comment by carl.dha...@gmail.com on 28 Jun 2010 at 12:00

GoogleCodeExporter commented 9 years ago
I have the same problem on Android 2.2.1 on Motorola Droid. Strangely enough, I 
do not have the problem on my Nexus One, only on the Motorola Droid.

Original comment by SSZer...@gmail.com on 4 Jan 2011 at 3:14

GoogleCodeExporter commented 9 years ago
Treatment of different mobile phone networks in different ways, cell phone 
manufacturers are custom android

Original comment by leadr...@gmail.com on 17 Jan 2011 at 9:51

GoogleCodeExporter commented 9 years ago
I have a same-problem.
On htc wildfire, xmpp don't generate an exception when close network.
This problem doesn't happen on other phones.
How to recognize exception when network lost. 

Thanks!

Original comment by hnbang1...@gmail.com on 11 Jul 2011 at 4:18

GoogleCodeExporter commented 9 years ago
We are heavy users of asmack in http://rogerthatmessenger.com

Whenever we get an XMPP connection closed on error, we create a new 
XMPPConnection object. That seems the only way to avoid unusable connections

Original comment by c...@mobicage.com on 3 Nov 2011 at 2:11

GoogleCodeExporter commented 9 years ago
Hi I am using asmack for developing android IM.I am facing problem on message 
receiving after reconnect network connection.
I am using a broadcast receiver with action as 
android.net.conn.CONNECTIVITY_CHANGE > to know is the internet reconnection 
(wifi or 3g)I have a service for listen incoming packets. When my device 
reconnect with internet from above broadcast active and hear a internet 
available that time I reconnect my application with Tigase Server and then I 
re-login on server that is fine. Same time I also again attaching listeners of 
my service so they can listen incoming packets. But When I send message it 
going to user B but User B sending me messages on my side its not receiving. on 
user B side it showing that user A Connected with new connection and also 
showing presence.Like to hear where I am doing wrong. . 

Original comment by tonasiri...@gmail.com on 30 Jun 2012 at 10:54