Skip to content

invoking ReadBytesAsync method sometimes never return #547

@yushu3166

Description

@yushu3166

code:
if (!await ConnectAsync())
{
return null;
}
Stopwatch stopwatch = Stopwatch.StartNew();
stopwatch.Start();
try
{
var cts = new CancellationTokenSource(1000 * 3);
byte[] bytes = await _Plc.ReadBytesAsync(DataType.DataBlock, DB, start, length, cts.Token);
stopwatch.Stop();
if (bytes == null || bytes.Length == 0)
{
_LogUtil.Error($"S7Plc error:{stopwatch.Elapsed.TotalMilliseconds},IP:{_Plc.IP},DB:{DB},start:{start},length:{length},MaxPDUSize:{_Plc.MaxPDUSize}");
}
return bytes;

}
catch (Exception ex)
{
stopwatch.Stop();
_LogUtil.Error($"S7Plc Exception:{stopwatch.Elapsed.TotalMilliseconds},IP:{_Plc.IP},DB:{DB},start:{start},length:{length},MaxPDUSize:{_Plc.MaxPDUSize}, ex:{ex.Message}");
}
return null;

=============

byte[] bytes = await _Plc.ReadBytesAsync(DataType.DataBlock, DB, start, length, cts.Token); // sometimes here never return or throw exception,why?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions