Рубрики
Uncategorized

Сокет Swoole / приложение websocket-пакет сердцебиения

Автор оригинала: David Wong.

Приложение Swoole websocket-пакет сердцебиения

Предпосылки: В официальной группе swoole кто-то спросил: “Мой клиент socket/web socket вышел из строя после успешного подключения в течение некоторого времени. Как мне его сохранить?”

Причины вопроса 1:

In practical applications, socket connections can be shut down by the host itself because there is no data for a long time.

Решение проблемы 1:

The heartbeat packet can be sent from server to client or client to server. In short, it can send a meaningless data periodically so that the machine knows that the current connection is active to avoid disconnection.

Оригинал: “https://developpaper.com/swoole-socket-websocket-application-heartbeat-package/”