@@ -114,7 +114,7 @@ namespace JT808.Gateway | |||||
var pipe = new Pipe(); | var pipe = new Pipe(); | ||||
Task writing = FillPipeAsync(session, pipe.Writer); | Task writing = FillPipeAsync(session, pipe.Writer); | ||||
Task reading = ReadPipeAsync(session, pipe.Reader); | Task reading = ReadPipeAsync(session, pipe.Reader); | ||||
await Task.WhenAll(reading, writing); | |||||
await Task.WhenAny(reading, writing); | |||||
SessionManager.RemoveBySessionId(session.SessionID); | SessionManager.RemoveBySessionId(session.SessionID); | ||||
}, jT808TcpSession); | }, jT808TcpSession); | ||||
} | } | ||||
@@ -245,7 +245,7 @@ namespace JT808.Gateway | |||||
} | } | ||||
catch (JT808Exception ex) | catch (JT808Exception ex) | ||||
{ | { | ||||
Logger.LogError($"[HeaderDeserialize ErrorCode]:{ ex.ErrorCode},[ReaderBuffer]:{data?.ToHexString()},{session.Client.RemoteEndPoint},{session.TerminalPhoneNo}"); | |||||
Logger.LogError($"[HeaderDeserialize ErrorCode]:{ex.ErrorCode},[ReaderBuffer]:{data?.ToHexString()},{session.Client.RemoteEndPoint},{session.TerminalPhoneNo}"); | |||||
} | } | ||||
totalConsumed += seqReader.Consumed - totalConsumed; | totalConsumed += seqReader.Consumed - totalConsumed; | ||||
if (seqReader.End) break; | if (seqReader.End) break; | ||||
@@ -4,8 +4,6 @@ using Microsoft.Extensions.Hosting; | |||||
using Microsoft.Extensions.Logging; | using Microsoft.Extensions.Logging; | ||||
using Microsoft.Extensions.Options; | using Microsoft.Extensions.Options; | ||||
using System; | using System; | ||||
using System.Collections.Generic; | |||||
using System.Text; | |||||
using System.Threading; | using System.Threading; | ||||
using System.Threading.Tasks; | using System.Threading.Tasks; | ||||
@@ -37,9 +35,17 @@ namespace JT808.Gateway.Services | |||||
{ | { | ||||
foreach (var item in SessionManager.GetTcpAll()) | foreach (var item in SessionManager.GetTcpAll()) | ||||
{ | { | ||||
if (item.ActiveTime.AddSeconds(Configuration.TcpReaderIdleTimeSeconds) < DateTime.Now) | |||||
try | |||||
{ | { | ||||
item.ReceiveTimeout.Cancel(); | |||||
if (item.ActiveTime.AddSeconds(Configuration.TcpReaderIdleTimeSeconds) < DateTime.Now) | |||||
{ | |||||
item.ReceiveTimeout.Cancel(); | |||||
} | |||||
} | |||||
catch (Exception e) | |||||
{ | |||||
Logger.LogError(e, "Check whether the session with id {id} and sim number {terminal} has timed out and failed.", item.SessionID, item.TerminalPhoneNo); | |||||
continue; | |||||
} | } | ||||
} | } | ||||
Logger.LogInformation($"[Check Receive Timeout]"); | Logger.LogInformation($"[Check Receive Timeout]"); | ||||