Otann / morse

📡 Clojure interface for Telegram Bot API
Eclipse Public License 1.0
257 stars 48 forks source link

Bot freezes for unknown reasons #32

Closed chiliec closed 6 years ago

chiliec commented 6 years ago

We use this code:

(defn -main
  [& args]
  (println "Bot running!")
  (go-loop [ch (p/start token bot-api)]
    (<! (timeout 5000))
    (if (nil? (<! ch))
      (do
        (println "Bot restarted")
        (recur (p/start token bot-api)))
      (recur ch)))
  (Thread/sleep Long/MAX_VALUE))

but bot freezes sometimes for unknown reasons 🤔

Otann commented 6 years ago

It looks like a duplicate of #31, there is a bug in clj-http that makes a call hang for an eternity.

In your code I recommend you to stop previous instance as well, you could be leaking memory with hanging threads.

chiliec commented 6 years ago
(defn -main
  [& args]
  (println "Bot running!")
  (go-loop [ch (p/start token bot-api)]
    (<! (timeout 5000))
    (if (nil? (<! ch))
      (do
        (println "Bot restarted")
        (p/stop ch)
        (recur (p/start token bot-api)))
      (recur ch)))
  (Thread/sleep Long/MAX_VALUE))

right? and what to do with this bug? 🤕

Otann commented 6 years ago

Yes, something like that! Hold on tight, I'm working on it ;)

chiliec commented 6 years ago

Okay, thanks, we believe in you!

Otann commented 6 years ago

@Chiliec Just FYI, I've released 0.3.2 to Clojars that should fix this

chiliec commented 6 years ago

Now just stopped after start:

Jan 25, 2018 2:29:20 PM morse.polling invoke
SEVERE: HTTP request timed out, stopping polling

It seems behavior changed and example usage in readme need to be updated?

Otann commented 6 years ago

@Chiliec oooops, found a stupid bug where I used seconds instead if milliseconds pushed 0.3.3 to clojars, would you be so kind to try again?

chiliec commented 6 years ago

If I set {timeout: 5000} than request timed out going away, but now enters to infinite loop (many answers).

dixel commented 6 years ago

@Chiliec @Otann I think it's not about the timeout but about the offset which is passed to telegram API, mb this would help? https://github.com/Otann/morse/pull/34/files

chiliec commented 6 years ago

@dixel thanks, it resolves my problem 👍

Otann commented 6 years ago

Released 0.3.4

chiliec commented 6 years ago

Thanks!