Otann/morse

Not reconnected after 502 error

Closed this issue · 4 comments

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.

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

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

Otann commented

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

Thank you @Otann.