如何解决如何确保JS gRPC客户端从grpc服务器收到消息?
我有一个聊天应用程序,客户端A(本机反应)通过gRPC服务器(转到)将消息发送到客户端B。在gRPC服务器中,从A收到消息并发送到B
if err := stream.Send(message); err != nil {
return err
}
在客户端B中,我关闭了Internet连接,但是gRPC服务器仍然发送成功而没有错误。我在下面的gRPC中的Send函数流文档中找到了
// SendMsg does not wait until the message is received by the client. An
// untimely stream closure may result in lost messages.
//
// It is safe to have a goroutine calling SendMsg and another goroutine
// calling RecvMsg on the same stream at the same time,but it is not safe
// to call SendMsg on the same stream in different goroutines.
SendMsg(m interface{}) error
因此,这意味着服务器不等待消息将成功发送给客户端。我不知道客户端何时断开连接,以致丢失了消息。我该如何处理这个问题?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。