Unobserved Task exceptions
- TShock version: 5.1.2.0
- TShock build number (if known):
Reproduction steps (if applicable)?
- Add TaskScheduler.UnobservedTaskException Event to TShockAPI (i added this on TShock.cs) or use a plugin with it (SEconomy for example)
- Join to the server and leave
- When you join or leave the server sometimes a System.AggregateException Shows up
Any stack traces or error messages (if known)?
System.AggregateException: A Task's exception(s) were not observed either by Waiting on the Task or accessing its Exception property. As a result, the unobserved exception was rethrown by the finalizer thread. (An established connection was aborted by the software in your host machine.)
---> System.Net.Sockets.SocketException (10053): An established connection was aborted by the software in your host machine.
at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.CreateException(SocketError error, Boolean forAsyncThrow)
at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.SendAsync(Socket socket, CancellationToken cancellationToken)
at System.Net.Sockets.NetworkStream.BeginWrite(Byte[] buffer, Int32 offset, Int32 count, AsyncCallback callback, Object state)
at TShockAPI.Sockets.LinuxTcpSocket.Terraria.Net.Sockets.ISocket.AsyncSend(Byte[] data, Int32 offset, Int32 size, SocketSendCallback callback, Object state) in /home/runner/work/TShock/TShock/TShockAPI/Sockets/LinuxTcpSocket.cs:line 143
at DMD<Terraria.Net.NetManager::SendData>(NetManager this, ISocket socket, NetPacket packet)
at Hook<Terraria.Net.NetManager::SendData>?43875021(NetManager , ISocket , NetPacket )
at Terraria.GameContent.NetModules.NetLiquidModule.PrepareAndSendToEachPlayerSeparately()
at Terraria.Liquid.UpdateLiquid()
at Terraria.WorldGen.UpdateWorld()
at Terraria.Main.DoUpdateInWorld(Stopwatch sw)
at Terraria.Main.DoUpdate(GameTime& gameTime)
at DMD<Terraria.Main::Update>(Main this, GameTime gameTime)
at TerrariaApi.Server.Hooking.GameHooks.OnUpdate(orig_Update orig, Main instance, GameTime gameTime) in /home/runner/work/TShock/TShock/TerrariaServerAPI/TerrariaServerAPI/TerrariaApi.Server/Hooking/GameHooks.cs:line 31
at Terraria.Main.DedServ()
at Terraria.Program.orig_RunGame()
at Terraria.Program.RunGame()
at Terraria.Program.LaunchGame(String[] args, Boolean monoArgs)
at Terraria.WindowsLaunch.orig_Main(String[] args)
at Terraria.WindowsLaunch.Main(String[] args)
at TerrariaApi.Server.Program.StartServer(String[] args) in /home/runner/work/TShock/TShock/TerrariaServerAPI/TerrariaServerAPI/Program.cs:line 123
at TerrariaApi.Server.Program.Main(String[] args) in /home/runner/work/TShock/TShock/TerrariaServerAPI/TerrariaServerAPI/Program.cs:line 106
at Program.<>c__DisplayClass0_0.<<Main>$>g__Start|1() in /home/runner/work/TShock/TShock/TShockLauncher/Program.cs:line 65
at Program.<Main>$(String[] args) in /home/runner/work/TShock/TShock/TShockLauncher/Program.cs:line 35
--- End of stack trace from previous location ---
--- End of inner exception stack trace ---
Any log messages from files that end in .log or .txt? What are the last 100 log messages from the server console?
2022-11-24_02-21-01 (with DebugLogs set to true).log 2022-11-24_02-19-02.log
What plugins and what versions of those plugins are you running?
Only TShockAPI, no other plugins.
Add TaskScheduler.UnobservedTaskException Event to TShockAPI (i added this on TShock.cs) or use a plugin with it (SEconomy for example)
Hello! Can you elaborate on this part? what code did you add?
I added this on initialize part of tshock.cs
TaskScheduler.UnobservedTaskException += TaskScheduler_UnobservedTaskException;
protected void TaskScheduler_UnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e)
{
if (e.Observed == true)
{
return;
}
TShock.Log.ConsoleError(e.Exception.Flatten().ToString());
e.SetObserved();
}
And this on dispose
TaskScheduler.UnobservedTaskException -= TaskScheduler_UnobservedTaskException;
EDIT: This error started to show up when i updated to tshock 5, it never happened to me before.
Here is some images of where i put the code