当客户端断开连接时,消息会在 zeromq pull/push 中丢失吗

Do messages drop in zeromq pull/push when client disconnects

我正在使用 ZMQ 允许多个客户端连接到服务器并使用 Pull/Push 模式发送视频数据流。现在的问题是客户端可以断开与服务器的连接。我需要问是否存在可靠性问题,如果发送到服务器的数据丢失会发生什么情况。客户端会从头开始发送视频流,还是从它在 ZeroMQ 中被丢弃的地方开始发送视频流。使用 Pull/Push 模式是否有缓冲区来解决这个问题。

通常 ZeroMQ 套接字会在连接因临时网络错误而丢失时自动重新连接。

对于 PUSH 套接字,documentation 状态:

When a PUSH socket enters the mute state due to having reached the high water mark for all downstream nodes, or if there are no downstream nodes at all, then any send operations on the socket will block until the mute state ends or at least one downstream node becomes available for sending; messages are not discarded.

因此,如果 PUSH 套接字未连接到下游 PULL 套接字,则 PUSH 套接字将缓冲数据并最终阻塞。

您应该可以通过暂时禁用或拔掉网络来进行测试。