Comments (8)
Same thing happened to me, any news on this issue yet?
Here
Line 43 in bbb2efc
I've added
(System/exit 1)
right after (close! updates)
, to crash app instead of freeze. This is a bad solution, but I haven't come up with anything better to prevent freezes :(
You can create file polling_patch.clj
:
(ns morse.polling-patch
(:require [morse.polling]))
(in-ns 'morse.polling)
(defn create-producer
"Passed channel should be always empty.
Close it to stop long-polling.
Returns channel with updates from Telegram"
[running token opts]
(let [updates (a/chan)
;; timeout for Telegram API in seconds
timeout (or (:timeout opts) 1)]
(go-loop [offset 0]
(let [;; fix for JDK bug https://bugs.openjdk.java.net/browse/JDK-8075484
;; introduce additional timeout 10 times more that telegram's one
wait-timeout (a/go (a/<! (a/timeout (* 1000 timeout 10)))
::wait-timeout)
response (api/get-updates-async token (assoc opts :offset offset))
[data _] (a/alts! [running response wait-timeout])]
(case data
;; running got closed by the user
nil
(do (log/info "Stopping Telegram polling...")
(close! wait-timeout)
(close! updates))
::wait-timeout
(do (log/error "HTTP request timed out, stopping polling")
(close! running)
(close! updates)
(log/fatal "ABORT")
(System/exit 1))
::api/error
(do (log/warn "Got error from Telegram API, stopping polling")
(close! running)
(close! updates))
(do (close! wait-timeout)
(doseq [upd data] (>! updates upd))
(recur (new-offset data offset))))))
updates))
(in-ns 'morse.polling-patch)
And then require this morse.polling-patch
somewhere in your project
from morse.
Thanks for the quick reply, I'll try it out!
from morse.
Thanks! I'll look into it soon.
As a temporary workaround, try maybe adding a timeout?
(def channel (p/start token handler {:timeout 10}))
from morse.
I have the same issue. Adding {:timeout 10}
didn't help
from morse.
Same thing happened to me, any news on this issue yet?
from morse.
I've added (System/exit 1) right after (close! updates), to crash app instead of freeze.
Thanks for the workaround. It really "solved" my problem. And I use it also for the ::api/error branch. Anyway, does anybody have an explanation why these problem arise in the first place?
from morse.
FWIW on ::api/error
I get:
SocketException The transport's socket appears to have lost its connection to the nREPL server
nrepl.transport/bencode/fn--9182/fn--9183 (transport.clj:108)
nrepl.transport/bencode/fn--9182 (transport.clj:108)
nrepl.transport/fn-transport/fn--9150 (transport.clj:55)
clojure.core/binding-conveyor-fn/fn--5739 (core.clj:2030)
java.util.concurrent.FutureTask.run (FutureTask.java:264)
java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1128)
java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:628)
java.lang.Thread.run (Thread.java:834)
Bye for now!
from morse.
Maybe it will be useful for somebody. 0.3.1 - the last version that works with long-polling without this issue. 0.3.2 was rewritten to use async that fails with time-out unfrotufately.
from morse.
Related Issues (20)
- Support /command@YourBot style commands HOT 3
- Exception causes long polling process shutdown HOT 2
- Don't leak dev-time dependencies HOT 3
- Not reconnected after 502 error HOT 4
- `polling/start` cannot signal when the updates channel is closed HOT 10
- Is it possible to pass a core.async channel to the "start" function in polling to get the updates directly into it? HOT 7
- Global timeout outside of clj-http for getting updates in the polling process. HOT 1
- Bot freezes for unknown reasons HOT 12
- Got HTTP request timed out HOT 2
- pooling started, but not working HOT 3
- Update handler HOT 1
- no delete-webhook function.
- Infinite loop with web hook HOT 1
- Handle upgrading a group to supergroup HOT 3
- Longpolling: Does not survive random 502 from Telegram HOT 3
- inline query did not check if update is a inline query
- 403 Forbidden: bot was blocked by the user HOT 4
- hellonico/morse 0.2.4 ? HOT 1
- Message is sent but throws an exception HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from morse.