Otann / morse

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

Not reconnected after 502 error #26

Closed chiliec closed 6 years ago

chiliec commented 6 years ago

We using morse.pooling. After telegram returning 502 error:

Oct 29, 2017 9:36:29 PM morse.api invoke
SEVERE: Telegram returned 502 from /getUpdates: <html>
<head><title>502 Bad Gateway</title></head>
<body bgcolor="white">
<center><h1>502 Bad Gateway</h1></center>
<hr><center>nginx/1.10.0</center>
</body>
</html>

bot stops receiving requests. But expected behavior is trying to reconnect.

jonathanj commented 6 years ago

I'm also experiencing this issue. I think the consumer loop exits and so no more updates are ever fetched.

The issue appears to be in the use of alts! in create-producer: (api/get-updates) returns nil (via log/error) when an error status code is returned, which means data (via alts!) is nil and thus the updates channel is closed and the create-consumer loop exits.

I think the producer code needs to check the channel value returned from alts! instead of throwing it away, if the channel is the running channel then indeed it's time to exit. If it's the resopnse channel then the loop should recur at the current offset.

Otann commented 6 years ago

@Chiliec Here, I fixed it. ;) Released 0.2.8 to clojars

Otann commented 6 years ago

@jonathanj you were right, changed nil to ::error

jonathanj commented 6 years ago

Thank you @Otann.