大佬教程收集整理的这篇文章主要介绍了第 3 个消息帧的 RSocket Net pipereader.ReadAsync 被截断,导致 MessageFramePeek 方法出错,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我使用 RSocket.Net 作为 Java Spring Boot RSocket 服务器的网络客户端。服务器将报价消息发送回客户端。示例代码一直工作到第 3 条引用消息,该消息被截断。
在RSocketProtocol.Handler.cs
static public async Task Handler(irsocketProtocol sink,PipeReader pipereader,CancellationToken cancellation)
{
Logs.Enter();
//The original implementation was a state-machine parser with resumability. It doesn't seem like the other implementations follow this pattern and the .NET folks are still figuring this out too - see th@R_772_9473@ernal JsON parser discussion for how they're handling state machine persistence across async boundarIEs when servicing a Pipeline. So,this version of the handler only processes complete messages at some cost to memory buffer scalability.
//Note that this means that the Pipeline must be configured to have enough buffering for a complete message before source-quenching. This also means that the downstream consumers don't really have to support resumption,so th@R_772_9473@erface no longer has the partial buffer methods in it.
while (!cancellation.IsCancellationrequested)
{
var read = await pipereader.ReadAsync(cancellation);
var buffer = read.buffer;
第一条消息是这样的,缓冲区大小为 942
下一条消息类似。那么第 3 条消息要么是 5657 的太大了!!?
或者它在 165 时太小了
这会导致 messageFramePeek
方法出错
static public (int Length,bool IsEndOfmessagE) messageFramePeek(ReadonlySequence<byte> sequencE) { var reader = new SequenceReader<byte>(sequencE); return reader.TryRead(out byte b1) && reader.TryRead(out byte b2) && reader.TryRead(out byte b3) ? ((b1 << 8 * 2) | (b2 << 8 * 1) | (b3 << 8 * 0),truE) : (0,falsE); }
updatE 我检查了服务器和客户端上的编码类型是 JsON,以便字符串不会与线路上的对象混合。仍然存在同样的问题。
updatE 如果 RSocket.Core 构建在网络标准或网络框架上,则会发生同样的问题。
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)
以上是大佬教程为你收集整理的第 3 个消息帧的 RSocket Net pipereader.ReadAsync 被截断,导致 MessageFramePeek 方法出错全部内容,希望文章能够帮你解决第 3 个消息帧的 RSocket Net pipereader.ReadAsync 被截断,导致 MessageFramePeek 方法出错所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。