优化Redis 接收逻辑

This commit is contained in:
2026-03-13 11:32:46 +08:00
parent 03a27dbde8
commit da7356f016
18 changed files with 254 additions and 17 deletions

View File

@@ -123,7 +123,7 @@ namespace RCUHost.Implement
try
{
var redis = CSRedisCacheHelper.redis1;
var data = redis.XReadGroup(group, consumer, 1000, 10, new ValueTuple<string, string>(UDPAllDataKey, ">"));
var data = redis.XReadGroup(group, consumer, 500, 10, new ValueTuple<string, string>(UDPAllDataKey, ">"));
if (data != null)
{
@@ -147,7 +147,7 @@ namespace RCUHost.Implement
}
catch (Exception ex)
{
logger.Error("消息队列失败:"+ex.Message);
logger.Error("消息队列失败:" + ex.Message);
}
}
@@ -169,7 +169,7 @@ namespace RCUHost.Implement
try
{
udpClient = new UdpClient(3339);
udpClient.Client.ReceiveBufferSize = 5 * 1024 * 1024;
udpClient.Client.ReceiveBufferSize = 3 * 1024 * 1024;
uint IOC_IN = 0x80000000;
uint IOC_VENDOR = 0x18000000;
uint SIO_UDP_CONNRESET = IOC_IN | IOC_VENDOR | 12;
@@ -459,6 +459,8 @@ namespace RCUHost.Implement
{
IPEndPoint remoteEP111 = new IPEndPoint(IPAddress.Any, 0);
byte[] receiveBuffer111 = state.UdpClient.EndReceive(ar, ref remoteEP111);
state.UdpClient.BeginReceive(ReceiveCallback, state);
if (receiveBuffer111.Length > 0)
{
@@ -719,17 +721,17 @@ namespace RCUHost.Implement
}
finally
{
try
{
if (this.udpClient != null)
{
state.UdpClient.BeginReceive(ReceiveCallback, new UdpState(this.udpClient));
}
}
catch
{
//try
//{
// if (this.udpClient != null)
// {
// state.UdpClient.BeginReceive(ReceiveCallback, new UdpState(this.udpClient));
// }
//}
//catch
//{
}
//}
}
}
@@ -1628,7 +1630,7 @@ namespace RCUHost.Implement
#region UDP丢掉的数据包总数
//insertcard 保留
//if (cmdType != 0x0E||cmdType!=0x01)
if (cmdType != 0E || cmdType != 0x03)
if (cmdType != 0E && cmdType != 0x03)
{
if (DataTongJi.DefineLostPackage != 0)
{