Closed ryebrand closed 5 months ago
When I try to establish a connection with the server using the following code on the client side, I receive this error. Can you help me out?
failed to WebSocket dial: response body is not a io.ReadWriteCloser: *http.cancelTimerBody
// 处理从服务器接收的消息 type receiver struct{} // ReceiveOrderStatus 回调方法,用于处理服务器的"ReceiveOrderStatus"调用 func (r *receiver) ReceiveOrderStatus(message string) { fmt.Println("New Message:", message) } headers := http.Header{} headers.Set("UserID", UserID) token, err := GetTokenFromRedis(context.Background(), UserID) if err != nil { fmt.Println("get token from redis error: ", err) return } headers.Set("Token", token) client, err = signalr.NewClient(context.Background(), nil, signalr.WithReceiver(&receiver{}), signalr.WithConnector(func() (signalr.Connection, error) { creationCtx, _ := context.WithTimeout(context.Background(), 5*time.Minute) //defer cancel() return signalr.NewHTTPConnection(creationCtx, address, signalr.WithHTTPHeaders(func() http.Header { return headers })) }), signalr.Logger(kitlog.NewLogfmtLogger(os.Stdout), true), ) if err != nil { fmt.Println("Error creating SignalR client:", err) return } // 启动signalR 客户端 client.Start() fmt.Println("Client started!!!")
i find this code will be error
This happens in nhooyr.io/websocket with the http.DefaultClient. Did you change http.DefaultClient? I do not think this is a problem caused somewhere in our repo.
When I try to establish a connection with the server using the following code on the client side, I receive this error. Can you help me out?
failed to WebSocket dial: response body is not a io.ReadWriteCloser: *http.cancelTimerBody