TShock/TShock — Issue #347: Server crash without error, exception on restart.
Author: ColinBohn
Created: 2012-02-03 22:49:12+00:00
State: open

Ok, so I'm having a problem with my server where it crashes at least once a day, with no errors in any of the logs. The server uses the scheduled task host and start-server.bat script to keep it on a loop, so when the server closes it automatically restarts itself. On restart, everything loads fine up until when it starts the server to accept players, at which point it stops with this error:

Starting server...
System.Net.Sockets.SocketException (0x80004005): Only one usage of each socket a
ddress (protocol/network address/port) is normally permitted
at System.Net.Sockets.Socket.DoBind(EndPoint endPointSnapshot, SocketAddress
socketAddress)
at System.Net.Sockets.Socket.Bind(EndPoint localEP)
at System.Net.Sockets.TcpListener.Start(Int32 backlog)
at Terraria.Netplay.ServerLoop(Object threadContext)

I'd assume that this exception is caused by the previous instance of the server not exiting properly, but the unknown cause of the original error and the freeze in the loop caused by the socket exception is causing me to have quite a bit of downtime. How would I be able to trace the cause of the original crash, and is it possible to have the server close itself on the socket exception so that the server will at least try to restart? I'll gladly provide any information needed that can help solve this.

Thanks,
Colin