codingteam / horta-hell

Configurable XMPP bot written in Scala based on the Akka framework.
MIT License
15 stars 8 forks source link

"Not connected to server" when trying to send a message #383

Open ForNeVeR opened 8 years ago

ForNeVeR commented 8 years ago

Horta somehow reconnected after receiving the message (that means it was indeed connected to server).

03:16:26.579 [CodingteamSystem-akka.actor.default-dispatcher-20486] DEBUG s.StatementExecutor$$anon$1 - [SQL Execution] insert into Log (time, room, sender, type, message) values ('2016-04-22 03:16:26.579', 'codingteam@conference.jabber.ru', 'ForNeVeR', 'message', 'send/gsomix/Есть же Aether:/'); (0 ms)
03:16:26.580 [CodingteamSystem-akka.actor.default-dispatcher-20483] ERROR akka.actor.OneForOneStrategy - Not connected to server.
java.lang.IllegalStateException: Not connected to server.
        at org.jivesoftware.smack.XMPPConnection.sendPacket(XMPPConnection.java:445) ~[horta-hell.jar:0.15.2]
        at org.jivesoftware.smack.ChatManager.sendMessage(ChatManager.java:259) ~[horta-hell.jar:0.15.2]
        at org.jivesoftware.smack.Chat.sendMessage(Chat.java:97) ~[horta-hell.jar:0.15.2]
        at ru.org.codingteam.horta.protocol.jabber.JabberProtocol$$anonfun$receive$1$$anonfun$applyOrElse$5.apply(JabberProtocol.scala:118) ~[horta-hell.jar:0.15.2]
        at ru.org.codingteam.horta.protocol.jabber.JabberProtocol$$anonfun$receive$1$$anonfun$applyOrElse$5.apply(JabberProtocol.scala:118) ~[horta-hell.jar:0.15.2]
        at ru.org.codingteam.horta.protocol.jabber.JabberProtocol.ru$org$codingteam$horta$protocol$jabber$JabberProtocol$$sendMessage(JabberProtocol.scala:188) ~[horta-hell.jar:0.15.2]
        at ru.org.codingteam.horta.protocol.jabber.JabberProtocol$$anonfun$receive$1.applyOrElse(JabberProtocol.scala:118) ~[horta-hell.jar:0.15.2]
        at akka.actor.Actor$class.aroundReceive(Actor.scala:465) ~[horta-hell.jar:0.15.2]
        at ru.org.codingteam.horta.protocol.jabber.JabberProtocol.aroundReceive(JabberProtocol.scala:19) ~[horta-hell.jar:0.15.2]
        at akka.actor.ActorCell.receiveMessage(ActorCell.scala:516) [horta-hell.jar:0.15.2]
        at akka.actor.ActorCell.invoke(ActorCell.scala:487) [horta-hell.jar:0.15.2]
        at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:238) [horta-hell.jar:0.15.2]
        at akka.dispatch.Mailbox.run(Mailbox.scala:220) [horta-hell.jar:0.15.2]
        at akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(AbstractDispatcher.scala:393) [horta-hell.jar:0.15.2]
        at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260) [horta-hell.jar:0.15.2]
        at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339) [horta-hell.jar:0.15.2]
        at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979) [horta-hell.jar:0.15.2]
        at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107) [horta-hell.jar:0.15.2]
03:16:26.581 [CodingteamSystem-akka.actor.default-dispatcher-20486] INFO  r.o.c.h.p.jabber.JabberProtocol - Disconnecting
03:16:26.737 [CodingteamSystem-akka.actor.default-dispatcher-20487] INFO  r.o.c.h.p.jabber.JabberProtocol - Disconnected

Maybe we're still leaking these connections / listeners somehow?

ForNeVeR commented 8 years ago

It seems that Horta sometimes may lose the message due to the connection problem. Here's the scenario:

  1. Horta receives send command.
  2. Horta thinks that the target user is in the room, so it tries to send the message to him.
  3. At this moment server suddenly reports Horta that it's disconnected.
  4. The message is lost (FAIL). It should be saved to the database instead. After that the disconnect should proceed as usual (e.g. rethrow an exception).
ForNeVeR commented 7 years ago

And another source of errors:

  1. Horta connects the room.
  2. Connection gets broken for some reason; it's even catched and properly logged.
  3. Connection is not closed; it's not recreated or something. The next message send will fail, kill the whole actor, and that's it.