From 29f7f7a1fe49f30b8b9401241e3d85518cd51c05 Mon Sep 17 00:00:00 2001 From: 0g-wh Date: Thu, 12 Dec 2024 04:58:13 +0000 Subject: [PATCH] fix websocket id type --- rpc/websockets.go | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/rpc/websockets.go b/rpc/websockets.go index a01136d2cb..00aaf77504 100644 --- a/rpc/websockets.go +++ b/rpc/websockets.go @@ -61,7 +61,7 @@ type WebsocketsServer interface { type SubscriptionResponseJSON struct { Jsonrpc string `json:"jsonrpc"` Result interface{} `json:"result"` - ID float64 `json:"id"` + ID string `json:"id"` } type SubscriptionNotification struct { @@ -231,13 +231,10 @@ func (s *websocketsServer) readLoop(wsConn *wsConn) { continue } - connID, ok := msg["id"].(float64) + connID, ok := msg["id"].(string) if !ok { - s.sendErrResponse( - wsConn, - fmt.Errorf("invalid type for connection ID: %T", msg["id"]).Error(), - ) - continue + // Convert msg["id"] to string if it is not already a string + connID = fmt.Sprintf("%v", msg["id"]) } switch method {