implemented connection with heartbeat