[bug] Seeing "XMPP Connection closed on error" a fair amount
Nov 24 02:35:50 107.170.123.187-1 logger: Lantern Client (5a4b47fdb8dd264567bb8a32adac38aLantern Client (5a4b47fdb8dd264567bb8a32adac38a0 / CN / Windows 8 / 1.5.9-05f5f31 / 1.7.0_25-b16) - WARN [Smack Packet Reader (0)] xmpp.XmppUtils.connectionClosedOnError (XmppUtils.java:566) - XMPP connection closed on error
Nov 24 02:35:50 107.170.123.187-1 logger: Lantern Client (5a4b47fdb8dd264567bb8a32adac38a0 / CN / Windows 8 / 1.5.9-05f5f31 / 1.7.0_25-b16) - WARN java.io.EOFException: no more data available - expected end tag </stream:stream> to close start tag <stream:stream> from line 1, parser stopped on END_TAG seen ...0-1d38-403b-a3cd-c2f2c0e9af7e",\n "ut" : 300000\n}</body></message>... @365:19
Nov 24 02:35:50 107.170.123.187-1 logger: Lantern Client (5a4b47fdb8dd264567bb8a32adac38a0 / CN / Windows 8 / 1.5.9-05f5f31 / 1.7.0_25-b16) - WARN at org.xmlpull.mxp1.MXParser.fillBuf(MXParser.java:3035)
Nov 24 02:35:50 107.170.123.187-1 logger: Lantern Client (5a4b47fdb8dd264567bb8a32adac38a0 / CN / Windows 8 / 1.5.9-05f5f31 / 1.7.0_25-b16) - WARN at org.xmlpull.mxp1.MXParser.more(MXParser.java:3046)
Nov 24 02:35:50 107.170.123.187-1 logger: Lantern Client (5a4b47fdb8dd264567bb8a32adac38a0 / CN / Windows 8 / 1.5.9-05f5f31 / 1.7.0_25-b16) - WARN at org.xmlpull.mxp1.MXParser.nextImpl(MXParser.java:1144)
Nov 24 02:35:50 107.170.123.187-1 logger: Lantern Client (5a4b47fdb8dd264567bb8a32adac38a0 / CN / Windows 8 / 1.5.9-05f5f31 / 1.7.0_25-b16) - WARN at org.xmlpull.mxp1.MXParser.next(MXParser.java:1093)
Nov 24 02:35:50 107.170.123.187-1 logger: Lantern Client (5a4b47fdb8dd264567bb8a32adac38a0 / CN / Windows 8 / 1.5.9-05f5f31 / 1.7.0_25-b16) - WARN at org.jivesoftware.smack.PacketReader.parsePackets(PacketReader.java:325)
Nov 24 02:35:50 107.170.123.187-1 logger: Lantern Client (5a4b47fdb8dd264567bb8a32adac38a0 / CN / Windows 8 / 1.5.9-05f5f31 / 1.7.0_25-b16) - WARN at org.jivesoftware.smack.PacketReader.access$000(PacketReader.java:43)
Nov 24 02:35:50 107.170.123.187-1 logger: Lantern Client (5a4b47fdb8dd264567bb8a32adac38a0 / CN / Windows 8 / 1.5.9-05f5f31 / 1.7.0_25-b16) - WARN at org.jivesoftware.smack.PacketReader$1.run(PacketReader.java:70)
Nov 24 02:35:50 107.170.123.187-1 logger: Lantern Client (5a4b47fdb8dd264567bb8a32adac38a0 / CN / Windows 8 / 1.5.9-05f5f31 / 1.7.0_25-b16) - INFO [Smack Packet Reader (0)] xmpp.XmppUtils.persistentXmppConnection (XmppUtils.java:289) - Removing stale connection
Nov 24 02:35:50 107.170.123.187-1 logger: Lantern Client (5a4b47fdb8dd264567bb8a32adac38a0 / CN / Windows 8 / 1.5.9-05f5f31 / 1.7.0_25-b16) - INFO [CometD-Sync-OnConnect-Thread] state.SyncService.run (SyncService.java:101) - Syncing with frontend...
Nov 24 04:01:48 107.170.123.187-1 logger: Lantern Client (5a4b47fdb8dd264567bb8a32adac38a0 / CN / Windows 8 / 1.5.9-05f5f31 / 1.7.0_25-b16) - ERROR [GetModeProxy-ClientToProxyWorker-6] impl.ClientToProxyConnection.exceptionCaught (ClientToProxyConnection.java:604) - (AWAITING_INITIAL) [id: 0x4b91d492, /127.0.0.1:64367 => /127.0.0.1:8787]: Caught an exception on ClientToProxyConnection
Nov 24 04:01:48 107.170.123.187-1 logger: Lantern Client (5a4b47fdb8dd264567bb8a32adac38a0 / CN / Windows 8 / 1.5.9-05f5f31 / 1.7.0_25-b16) - ERROR java.io.IOException: Զ������ǿ�ȹر���һ�����е����ӡ�
Nov 24 04:01:48 107.170.123.187-1 logger: Lantern Client (5a4b47fdb8dd264567bb8a32adac38a0 / CN / Windows 8 / 1.5.9-05f5f31 / 1.7.0_25-b16) - ERROR at sun.nio.ch.SocketDispatcher.read0(Native Method)
Nov 24 04:01:48 107.170.123.187-1 logger: Lantern Client (5a4b47fdb8dd264567bb8a32adac38a0 / CN / Windows 8 / 1.5.9-05f5f31 / 1.7.0_25-b16) - ERROR at sun.nio.ch.SocketDispatcher.read(Unknown Source)
Nov 24 04:01:48 107.170.123.187-1 logger: Lantern Client (5a4b47fdb8dd264567bb8a32adac38a0 / CN / Windows 8 / 1.5.9-05f5f31 / 1.7.0_25-b16) - ERROR at sun.nio.ch.IOUtil.readIntoNativeBuffer(Unknown Source)
Nov 24 04:01:48 107.170.123.187-1 logger: Lantern Client (5a4b47fdb8dd264567bb8a32adac38a0 / CN / Windows 8 / 1.5.9-05f5f31 / 1.7.0_25-b16) - ERROR at sun.nio.ch.IOUtil.read(Unknown Source)
Nov 24 04:01:48 107.170.123.187-1 logger: Lantern Client (5a4b47fdb8dd264567bb8a32adac38a0 / CN / Windows 8 / 1.5.9-05f5f31 / 1.7.0_25-b16) - ERROR at sun.nio.ch.SocketChannelImpl.read(Unknown Source)
Nov 24 04:01:48 107.170.123.187-1 logger: Lantern Client (5a4b47fdb8dd264567bb8a32adac38a0 / CN / Windows 8 / 1.5.9-05f5f31 / 1.7.0_25-b16) - ERROR at io.netty.buffer.UnpooledUnsafeDirectByteBuf.setBytes(UnpooledUnsafeDirectByteBuf.java:446)
Nov 24 04:01:48 107.170.123.187-1 logger: Lantern Client (5a4b47fdb8dd264567bb8a32adac38a0 / CN / Windows 8 / 1.5.9-05f5f31 / 1.7.0_25-b16) - ERROR at io.netty.buffer.AbstractByteBuf.writeBytes(AbstractByteBuf.java:871)
Nov 24 04:01:48 107.170.123.187-1 logger: Lantern Client (5a4b47fdb8dd264567bb8a32adac38a0 / CN / Windows 8 / 1.5.9-05f5f31 / 1.7.0_25-b16) - ERROR at io.netty.channel.socket.nio.NioSocketChannel.doReadBytes(NioSocketChannel.java:208)
Nov 24 04:01:48 107.170.123.187-1 logger: Lantern Client (5a4b47fdb8dd264567bb8a32adac38a0 / CN / Windows 8 / 1.5.9-05f5f31 / 1.7.0_25-b16) - ERROR at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:118)
Nov 24 04:01:48 107.170.123.187-1 logger: Lantern Client (5a4b47fdb8dd264567bb8a32adac38a0 / CN / Windows 8 / 1.5.9-05f5f31 / 1.7.0_25-b16) - ERROR at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:485)
Nov 24 04:01:48 107.170.123.187-1 logger: Lantern Client (5a4b47fdb8dd264567bb8a32adac38a0 / CN / Windows 8 / 1.5.9-05f5f31 / 1.7.0_25-b16) - ERROR at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:452)
Nov 24 04:01:48 107.170.123.187-1 logger: Lantern Client (5a4b47fdb8dd264567bb8a32adac38a0 / CN / Windows 8 / 1.5.9-05f5f31 / 1.7.0_25-b16) - ERROR at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:346)
Nov 24 04:01:48 107.170.123.187-1 logger: Lantern Client (5a4b47fdb8dd264567bb8a32adac38a0 / CN / Windows 8 / 1.5.9-05f5f31 / 1.7.0_25-b16) - ERROR at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:101)
Nov 24 04:01:48 107.170.123.187-1 logger: Lantern Client (5a4b47fdb8dd264567bb8a32adac38a0 / CN / Windows 8 / 1.5.9-05f5f31 / 1.7.0_25-b16) - ERROR at java.lang.Thread.run(Unknown Source)
Yup this is the forth most common error at this point. It hopefully doesn't indicate an issue with maintaining long-lived connections with Flashlight, but my inclination is to let it be for now pending full Waddell integration.
This also appears to be the root cause of #2024 and #2022
(Prioritizing to address sooner because @myleshorton is concerned that this might be indicative of some deeper problem in maintaining long-lived connections through proxies.)
I'm trying SmackConfiguration.setKeepAliveInterval(5 * 1000); inside DefaultXmppHandler. I'm running over night to see if I get any of these errors. If not, I'll pull request.
Oh nice!! Great find.
On Thu, Dec 4, 2014 at 8:58 PM, oxtoacart [email protected] wrote:
I'm trying SmackConfiguration.setKeepAliveInterval(5 * 1000); inside DefaultXmppHandler. I'm running over night to see if I get any of these errors. If not, I'll pull request.
— Reply to this email directly or view it on GitHub https://github.com/getlantern/lantern/issues/2006#issuecomment-65747725.
President Brave New Software Project, Inc. https://www.getlantern.org pgp A998 2B6E EF1C 373E 723F A813 045D A255 901A FD89
Lantern ran over night with no XMPP errors. Submitting PR.
This is great! Closing.
Marking as a hotfix (p0) because this is a very stable change and is is causing core functionality to break in production.
Unfortunately the keep alive change didn't knock this out -- still happening quite a bit.
@myleshorton Bummer. You're seeing this in production? The latest production release for which I'm seeing the error in great quantity in Loggly is 1.5.13. I do see a handful of these errors for 1.5.14 snapshots in Loggly.
1.5.13 doesn't have the fix - https://github.com/getlantern/lantern/blob/lantern-1.5.13/src/main/java/org/lantern/DefaultXmppHandler.java#L89
I wonder if the production 1.5.14 will exhibit this error less frequently than prior releases. In that case, we may have fixed disconnects due to idle timeouts but there may be another cause of disconnects.
Actually 1.5.14 is now in production with just that change, and it's happening comparably frequently.
On Tuesday, December 9, 2014, oxtoacart [email protected] wrote:
@myleshorton https://github.com/myleshorton Bummer. You're seeing this in production? The latest production release for which I'm seeing the error in great quantity in Loggly is 1.5.13. I do see a handful of these errors for 1.5.14 snapshots in Loggly.
1.5.13 doesn't have the fix - https://github.com/getlantern/lantern/blob/lantern-1.5.13/src/main/java/org/lantern/DefaultXmppHandler.java#L89
I wonder if the production 1.5.14 will exhibit this error less frequently than prior releases. In that case, we may have fixed disconnects due to idle timeouts but there may be another cause of disconnects.
— Reply to this email directly or view it on GitHub https://github.com/getlantern/lantern/issues/2006#issuecomment-66373099.
President Brave New Software Project, Inc. https://www.getlantern.org pgp A998 2B6E EF1C 373E 723F A813 045D A255 901A FD89
Oh yeah, I see it now - there's quite a number of unique reporterIds for that error on 1.5.14-9280775.
Exactly.
Interestingly, the geographic distribution of this error seems to be broad. I had assumed it was only happening in Get mode, but perhaps it's happening in Give mode too ... Also interestingly, Iran is the far and away leader in terms of seeing this error reported.

Correction on that last comment - I had a filter on country = "US". Removing that filter, we see the below distribution, in which China is in first place, followed by Iran, then USA.

So just to make sure I wasn't crazy, I did a little testing from the command-line on the devel branch.
- Running with the code as-is on devel, I was not able to get this error
- I then tried running with the --force-flashlight flag, still didn't get the error
- I then changed the keep-alive interval in DefaultXmppHandler to 500 * 1000, at which point I started to see the error frequently, but only when running with --force-flashlight. Without --force-flashlight, even with the high keep-alive interval, I don't see the error.
I also tried to stimulate the error by disconnecting the network. That did allow me to sometimes see an "XMPP Connection closed on error", but not with the "expected end tag ..." message, rather something about a socket timeout getting hit.
So it looks like the short keep-alive interval at least helps when running over flashlight, but there must be something else going on, something other than just losing network connectivity.
Thanks @oxtoacart. The other time I've definitely seen this is on shutdown, when it makes some sense this might happen -- i.e.:
- The XMPP connection is tunneled through the local proxy
- The user shuts down Lantern
- The local proxy closes
- The XMPP connection just sees a closed connection
It seems definitely possible that the keepalive limited the occurrences of this to only shutdown. It's a little tricky to tell if a shutdown event has happened, however. The other useful data point is the various errors that happen when users invite if the XMPP connection is dead. The messages for those errors are:
"ERROR_EMAILING_FRIEND" "ERROR_ADDING_FRIEND"
The problem is that they don't happen very often, so their absence over the short term isn't indicative of much. If we don't see them over a longer stretch with the keep alive change, however, it's likely the keep alive change did, in fact, fix this issue. Here's the one trick we could use to also add shutdown info to the logs:
public static boolean isShuttingDown() {
final Thread shutdown = new Thread();
try {
Runtime.getRuntime().addShutdownHook(shutdown);
Runtime.getRuntime().removeShutdownHook(shutdown);
} catch ( IllegalStateException e ) {
return true;
}
return false;
}
@myleshorton That's a nice hypothesis and good test.
Regarding shutdown logic in general - right now, flashlight doesn't have any shutdown logic. It just exits. This means that if there are any outstanding ops queued up like a stats update or whatever, they won't get flushed. Given that the process may always exit prematurely anyway (e.g. if it gets killed by the OS), I'm inclined to say that as long as the program is able to start successfully after any kind of termination, that's good enough, and that the complexity of a shutdown sequence is perhaps best avoided. What do you think?
Yeah I think it just depends on what we're doing. One of the main things Lantern does on shutdown is unmap UPnP and NAT-PMP ports, for example, which is just generally good hygiene. There also might be things like files to clean up, state to save one last time, etc.
The theory above isn't that this error comes up as a result of a shutdown sequence, though, but rather that connections to the proxy inevitably get dropped by the proxy as Lantern is shutting down (i.e. the server socket is closed), causing it to report an error as that may only be happening at shutdown.
On Sat, Dec 13, 2014 at 7:20 AM, oxtoacart [email protected] wrote:
@myleshorton https://github.com/myleshorton That's a nice hypothesis and good test.
Regarding shutdown logic in general - right now, flashlight doesn't have any shutdown logic. It just exits. This means that if there are any outstanding ops queued up like a stats update or whatever, they won't get flushed. Given that the process may always exit prematurely anyway (e.g. if it gets killed by the OS), I'm inclined to say that as long as the program is able to start successfully after any kind of termination, that's good enough, and that the complexity of a shutdown sequence is perhaps best avoided. What do you think?
— Reply to this email directly or view it on GitHub https://github.com/getlantern/lantern/issues/2006#issuecomment-66879574.
President Brave New Software Project, Inc. https://www.getlantern.org pgp A998 2B6E EF1C 373E 723F A813 045D A255 901A FD89
+1 on being good citizens and cleaning up stuff like mapped ports. That sort of stuff is probably the exception rather than the rule though.
Regarding the XMPP connection stuff, I guess I'm just saying that if we kill the process (or System.exit(0)), the XMPP code won't have time to complain about anything :)