Example of a WebSocket server with heartbeats import asyncio import websockets import json self.eventloop = eventloop # asyncio-eventloop - we need this to be able to run coroutines and await awaitables from action code self.socket = socket self.eventloop = eventloop