fix 心跳间隔

This commit is contained in:
2024-02-23 19:30:59 +08:00
parent 96cbaa1c3a
commit 07fdbd2f16
2 changed files with 6 additions and 3 deletions

View File

@@ -31,11 +31,14 @@ public class HeartbeatJob
{
var ipInfo = JsonConvert.DeserializeObject<IPPortDto>(device.ConnectionInfo);
await new TcpClient().ConnectAsync(IPAddress.Parse(ipInfo.IP), ipInfo.Port);
//超时时间
var CancellationTokenSource = new CancellationTokenSource(300);
await new TcpClient().ConnectAsync(IPAddress.Parse(ipInfo.IP), ipInfo.Port, CancellationTokenSource.Token);
await _dbContext.Updateable<DeviceRegistryEntity>().SetColumns(x => x.LastHeartbeatTime == DateTime.Now)
.Where(x => x.DeviceUniqueNo == device.UniqueNo).ExecuteCommandAsync();
_logger.LogInformation("心跳设备:{no}成功", device.UniqueNo);
_logger.LogInformation("心跳设备成功:{no}", device.UniqueNo);
}
catch (Exception ex)
{

View File

@@ -43,7 +43,7 @@ public class JobPack : BaseAppPack
});
//心跳
RecurringJob.AddOrUpdate<HeartbeatJob>("Heartbeat", s => s.RunAsync(), "10 * * * * ?", new RecurringJobOptions
RecurringJob.AddOrUpdate<HeartbeatJob>("Heartbeat", s => s.RunAsync(), "0/10 * * * * ?", new RecurringJobOptions
{
TimeZone = TimeZoneInfo.Local
});