-
Notifications
You must be signed in to change notification settings - Fork 8
Needs pinging to keep bot(s) alive #50
Comments
|
Thanks for the link, I don't think that existed at the time. Do you know if this is required or optional ? I will have to thing of a way to include that for all IO implementation. In the meantime I suggest you subclass the
|
I'm not sure honestly. I would assume it's required as my bots generally stop responding after a time.
On December 6, 2018 1:15:36 PM EST, Quentin Dawans ***@***.***> wrote:
Thanks for the link, I don't think that existed at the time. Do you
know if this is required or optional ? I will have to thing of a way to
include that for all IO implementation.
In the meantime I suggest you subclass the `aiohttp` implementation and
change the `_rtm` function to expose the websocket object. Something
like:
```
from slack.io.aiohttp import SlackAPI
class ClientWithWS:
async def _rtm:
async with self._session.ws_connect(url) as self.ws:
async for data in self.ws:
if data.type == aiohttp.WSMsgType.TEXT:
yield data.data
elif data.type == aiohttp.WSMsgType.CLOSED:
break
elif data.type == aiohttp.WSMsgType.ERROR:
break
```
Casey Weed
|
Ok thanks, I'll have to test it out. I have stopped using the websocket connection a long time ago as the HTTP events API is much more reliable (on a side note there is a linked project helping with that: https://github.com/pyslackers/sir-bot-a-lot-2/) |
Cool, thank you.
On December 6, 2018 1:18:57 PM EST, Quentin Dawans ***@***.***> wrote:
Ok thank, I'll have to test it out. I have stopped using the websocket
connection a long time ago as the HTTP events API is much more reliable
(on a side note there is a linked project helping with that:
https://github.com/pyslackers/sir-bot-a-lot-2/)
Casey Weed
|
Most mature websocket clients & servers do ping/pong health checks automatically. |
@iMerica in that case it might just be something broke for my bot instead, in which case this issue can probably be ignored |
@iMerica it's a custom slack JSON ping. From the documentation it looks like it's optional. I think the issue is slack closing the connection after a while, a Not sure if adding the ping would tell slack to not close it 🤔 |
This may need some sort of periodic task that sends a ping over the websocket to prevent bots from disconnecting. See "Ping and Pong".
I've seen it done like the following:
with the keepalive task created shortly after startup like so:
The text was updated successfully, but these errors were encountered: