Otann / morse

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

Longpolling: Does not survive random 502 from Telegram #44

Open LeviSchuck opened 5 years ago

LeviSchuck commented 5 years ago

My bot did not resume polling after encountering a 502 from Telegram by longpolling.

Exception in thread "async-dispatch-18" clojure.lang.ExceptionInfo: clj-http: status 502 {:cached nil, :request-time 6929, :repeatable? false, :protocol-version {:name "HTTP", :major 1, :minor 1}, :streaming? true, :http-client #object[org.apache.http.impl.client.InternalHttpClient 0x6e992d0a "org.apache.http.impl.client.InternalHttpClient@6e992d0a"], :chunked? false, :type :clj-http.client/unexceptional-status, :reason-phrase "Bad Gateway", :headers {"Server" "nginx/1.12.2", "Date" "Sun, 28 Oct 2018 01:16:34 GMT", "Content-Type" "application/json", "Content-Length" "57", "Connection" "close", "Access-Control-Allow-Origin" "*", "Access-Control-Expose-Headers" "Content-Length,Content-Type,Date,Server,Connection"}, :orig-content-encoding nil, :status 502, :length 57, :body "{\"ok\":false,\"error_code\":502,\"description\":\"Bad Gateway\"}", :trace-redirects []}
    at slingshot.support$stack_trace.invoke(support.clj:201)
    at clj_http.client$exceptions_response.invokeStatic(client.clj:245)
    at clj_http.client$exceptions_response.invoke(client.clj:236)
    at clj_http.client$wrap_exceptions$fn__10385.invoke(client.clj:254)
    at clj_http.client$wrap_accept$fn__10627.invoke(client.clj:737)
    at clj_http.client$wrap_accept_encoding$fn__10634.invoke(client.clj:759)
    at clj_http.client$wrap_content_type$fn__10621.invoke(client.clj:720)
    at clj_http.client$wrap_form_params$fn__10724.invoke(client.clj:961)
    at clj_http.client$wrap_nested_params$fn__10741.invoke(client.clj:995)
    at clj_http.client$wrap_flatten_nested_params$fn__10750.invoke(client.clj:1019)
    at clj_http.client$wrap_method$fn__10682.invoke(client.clj:895)
    at clj_http.cookies$wrap_cookies$fn__7853.invoke(cookies.clj:131)
    at clj_http.links$wrap_links$fn__9284.invoke(links.clj:63)
    at clj_http.client$wrap_unknown_host$fn__10758.invoke(client.clj:1048)
    at clj_http.client$request_STAR_.invokeStatic(client.clj:1176)
    at clj_http.client$request_STAR_.invoke(client.clj:1169)
    at clj_http.client$get.invokeStatic(client.clj:1182)
    at clj_http.client$get.doInvoke(client.clj:1178)
    at clojure.lang.RestFn.invoke(RestFn.java:423)
    at morse.api$get_updates.invokeStatic(api.clj:17)
    at morse.api$get_updates.invoke(api.clj:10)

Would recommend retrying a connection every 10-30 seconds as longpolling sessions may be arbitrarily resumed later

LeviSchuck commented 5 years ago

It's happened several times each day by now, the program still runs but is no longer listening. I'm more familiar with java than clojure so I'm not really sure about supplying a PR

LeviSchuck commented 4 years ago

Webhooks require an externally available endpoint which may not be provisioned for small personal projects. This is a valid use of the telegram bots API, so that comment was not constructive @l0rem

Due to this issue I have backed down to Java and no longer am using this library.

ilevd commented 2 years ago

It seems it has been fixed in 8fa55c1f27e28dea13f9cec6006696509736f76f