From bb2a4c720ebaaf8345e98f8a6c030283eca3bd79 Mon Sep 17 00:00:00 2001 From: ZhouYongyou <128128010+zhouyongyou@users.noreply.github.com> Date: Wed, 5 Nov 2025 01:10:49 +0800 Subject: [PATCH] =?UTF-8?q?fix(market):=20prevent=20program=20crash=20on?= =?UTF-8?q?=20WebSocket=20failure=20##=20Problem=20-=20Program=20crashes?= =?UTF-8?q?=20with=20log.Fatalf=20when=20WebSocket=20connection=20fails=20?= =?UTF-8?q?-=20Triggered=20by=20WebSocket=20hijacking=20issue=20(157.240.1?= =?UTF-8?q?2.50)=20-=20Introduced=20in=20commit=203b1db6f=20(K-line=20WebS?= =?UTF-8?q?ocket=20migration)=20##=20Solution=20-=20Replace=204x=20log.Fat?= =?UTF-8?q?alf=20with=20log.Printf=20in=20monitor.go=20-=20Lines=20177,=20?= =?UTF-8?q?183,=20189,=20215=20-=20Program=20now=20logs=20error=20and=20co?= =?UTF-8?q?ntinues=20running=20##=20Changes=201.=20Initialize=20failure:?= =?UTF-8?q?=20Fatalf=20=E2=86=92=20Printf=20(line=20177)=202.=20Connection?= =?UTF-8?q?=20failure:=20Fatalf=20=E2=86=92=20Printf=20(line=20183)=203.?= =?UTF-8?q?=20Subscribe=20failure:=20Fatalf=20=E2=86=92=20Printf=20(line?= =?UTF-8?q?=20189)=204.=20K-line=20subscribe:=20Fatalf=20=E2=86=92=20Print?= =?UTF-8?q?f=20+=20dynamic=20period=20(line=20215)=20##=20Fallback=20-=20S?= =?UTF-8?q?ystem=20automatically=20uses=20API=20when=20WebSocket=20cache?= =?UTF-8?q?=20is=20empty=20-=20GetCurrentKlines()=20has=20built-in=20degra?= =?UTF-8?q?dation=20mechanism=20-=20No=20data=20loss,=20slightly=20slower?= =?UTF-8?q?=20API=20calls=20as=20fallback=20##=20Impact=20-=20=E2=9C=85=20?= =?UTF-8?q?Program=20stability:=20Won't=20crash=20on=20network=20issues=20?= =?UTF-8?q?-=20=E2=9C=85=20Error=20visibility:=20Clear=20error=20messages?= =?UTF-8?q?=20in=20logs=20-=20=E2=9C=85=20Data=20integrity:=20API=20fallba?= =?UTF-8?q?ck=20ensures=20K-line=20availability=20Related:=20websocket-hij?= =?UTF-8?q?ack-fix.md,=20auto-stop-bug-analysis.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- market/monitor.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/market/monitor.go b/market/monitor.go index 23e126d9..033e1685 100644 --- a/market/monitor.go +++ b/market/monitor.go @@ -121,19 +121,19 @@ func (m *WSMonitor) Start(coins []string) { // 初始化交易对 err := m.Initialize(coins) if err != nil { - log.Fatalf("❌ 初始化币种: %v", err) + log.Printf("❌ 初始化币种失败: %v", err) return } err = m.combinedClient.Connect() if err != nil { - log.Fatalf("❌ 批量订阅流: %v", err) + log.Printf("❌ 批量订阅流失败: %v", err) return } // 订阅所有交易对 err = m.subscribeAll() if err != nil { - log.Fatalf("❌ 订阅币种交易对: %v", err) + log.Printf("❌ 订阅币种交易对失败: %v", err) return } } @@ -159,7 +159,7 @@ func (m *WSMonitor) subscribeAll() error { for _, st := range subKlineTime { err := m.combinedClient.BatchSubscribeKlines(m.symbols, st) if err != nil { - log.Fatalf("❌ 订阅3m K线: %v", err) + log.Printf("❌ 订阅 %s K线失败: %v", st, err) return err } }