Fixed bug which caused the UDP and TCP Listeners to shut down on improperly formatted JSON
This commit is contained in:
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.3.15.0")]
|
||||
[assembly: AssemblyFileVersion("1.3.15.0")]
|
||||
[assembly: AssemblyVersion("1.3.16.0")]
|
||||
[assembly: AssemblyFileVersion("1.3.16.0")]
|
||||
|
||||
@@ -105,9 +105,17 @@ namespace TimberWinR.Inputs
|
||||
while (reader.Read())
|
||||
{
|
||||
if (CancelToken.IsCancellationRequested) break;
|
||||
JObject json = JObject.Load(reader);
|
||||
ProcessJson(json);
|
||||
_receivedMessages++;
|
||||
try
|
||||
{
|
||||
JObject json = JObject.Load(reader);
|
||||
ProcessJson(json);
|
||||
_receivedMessages++;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogManager.GetCurrentClassLogger().Warn(ex);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ namespace TimberWinR.Inputs
|
||||
_udpListener = new System.Net.Sockets.UdpClient(port);
|
||||
|
||||
_listenThreadV4 = new Thread(new ParameterizedThreadStart(StartListener));
|
||||
_listenThreadV4.Start(new listenProfile() {endPoint = groupV4, client = _udpListener});
|
||||
_listenThreadV4.Start(new listenProfile() { endPoint = groupV4, client = _udpListener });
|
||||
|
||||
_listenThreadV6 = new Thread(new ParameterizedThreadStart(StartListener));
|
||||
_listenThreadV6.Start(new listenProfile() { endPoint = groupV6, client = _udpListener });
|
||||
@@ -77,10 +77,17 @@ namespace TimberWinR.Inputs
|
||||
while (!CancelToken.IsCancellationRequested)
|
||||
{
|
||||
byte[] bytes = profile.client.Receive(ref profile.endPoint);
|
||||
var data = Encoding.ASCII.GetString(bytes, 0, bytes.Length);
|
||||
JObject json = JObject.Parse(data);
|
||||
ProcessJson(json);
|
||||
_receivedMessages++;
|
||||
try
|
||||
{
|
||||
var data = Encoding.ASCII.GetString(bytes, 0, bytes.Length);
|
||||
JObject json = JObject.Parse(data);
|
||||
ProcessJson(json);
|
||||
_receivedMessages++;
|
||||
}
|
||||
catch (Exception ex1)
|
||||
{
|
||||
LogManager.GetCurrentClassLogger().Warn(ex1);
|
||||
}
|
||||
}
|
||||
_udpListener.Close();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user