diff --git a/third_party/dynamics/dynamics.go b/third_party/dynamics/dynamics.go index 52d928f..4b18cae 100644 --- a/third_party/dynamics/dynamics.go +++ b/third_party/dynamics/dynamics.go @@ -78,6 +78,7 @@ func newDynamics() Dynamics { }, } d.trainInfoUdpServer = udp.NewServer(fmt.Sprintf(":%d", config.Config.Dynamics.UdpLocalPort), d.handleDynamicsTrainInfo) + d.trainInfoUdpServer.Listen() return d } diff --git a/third_party/semi_physical_train/semi_physical_train.go b/third_party/semi_physical_train/semi_physical_train.go index 3e03f02..606ecfd 100644 --- a/third_party/semi_physical_train/semi_physical_train.go +++ b/third_party/semi_physical_train/semi_physical_train.go @@ -49,6 +49,7 @@ func newSemiPhysicalTrain() SemiPhysicalTrain { trainSpeedInfoUdpClient: udp.NewClient("127.0.0.1:7777"), } s.trainControlUdpServer = udp.NewServer(fmt.Sprintf(":%d", config.Config.Dynamics.UdpLocalPort), s.handleTrainControlMsg) + s.trainControlUdpServer.Listen() return s } diff --git a/third_party/udp/udp_server.go b/third_party/udp/udp_server.go index 3947246..9566798 100644 --- a/third_party/udp/udp_server.go +++ b/third_party/udp/udp_server.go @@ -3,6 +3,7 @@ package udp import ( "log/slog" "net" + "runtime/debug" ) type UdpServer interface { @@ -54,7 +55,8 @@ func (s *server) listenAndHandle() { func (s *server) handle(b []byte) { defer func() { if err := recover(); err != nil { - slog.Error("udp server handle error", err) + slog.Error("udp server handle error", "error", err, "stack", string(debug.Stack())) + debug.PrintStack() } }() // slog.Info("udp server handle", "msg", string(b))