where is the error, help ! connect websoket -BOOKTIKER

url = “wss://stream.binance.com:9443/ws/stream?streams=”;
string url2 = url.ToLower();
webSocketClient = new WebSocket(url2);
webSocketClient.OnError += new EventHandler<WebSocketSharp.ErrorEventArgs>(webSocketClient_Error);
webSocketClient.OnOpen += new EventHandler(webSocketClient_Opened);
webSocketClient.OnClose += new EventHandler<WebSocketSharp.CloseEventArgs>(webSocketClient_Closed);
webSocketClient.OnMessage += new EventHandler(webSocketClient_MessageReceived);
webSocketClient.ConnectAsync();

private async void webSocketClient_Opened(object sender, EventArgs e)
{

        Subscribe();
    }

    private void Subscribe()
    {
        var requestString = $"{{\"method\": \"SUBSCRIBE\", \"params\": [\"!bookTicker\"], \"id\": 1}}";
         webSocketClient.Send(requestString);
    
    }

Please convert the JSON object to a string before ws.send; Not sure how the double curly brackets do it

here they are, I also tried this , maybe the address is not the same or I don’t understand the syntax already

    private void Subscribe()
    {
        var requestString = $"{{\"method\": \"SUBSCRIBE\", \"params\": [\"!bookTicker\"], \"id\": 1}}";
         
        webSocketClient.Send(JsonConvert.SerializeObject(requestString));
    }
public void start()
    {
       
        
        url = "wss://stream.binance.com:9443/ws";
        string url2 = url.ToLower();
        webSocketClient = new WebSocket(url2);
        webSocketClient.OnError += new EventHandler<WebSocketSharp.ErrorEventArgs>(webSocketClient_Error);
        webSocketClient.OnOpen += new EventHandler(webSocketClient_Opened);
        webSocketClient.OnClose += new EventHandler<WebSocketSharp.CloseEventArgs>(webSocketClient_Closed);
        webSocketClient.OnMessage += new EventHandler<MessageEventArgs>(webSocketClient_MessageReceived);
        webSocketClient.ConnectAsync();
        
            // webSocketClient.Connect();

        while (!webSocketClient.IsAlive)
        {
            Savelog("Connecting via WebSocket to Binance......\r\n", Color.DarkGreen);
            Thread.Sleep(2000);
        }
       //SubscribeStream();
        t.Elapsed += new System.Timers.ElapsedEventHandler(heatBeat);
        t.Start();
    }


    private async void webSocketClient_Opened(object sender, EventArgs e)
    {

        Subscribe();
    }

    private void Subscribe()
    {
        var requestString = $"{{\"method\": \"SUBSCRIBE\", \"params\": [\"!bookTicker\"], \"id\": 1}}";
        // webSocketClient.Send(requestString);
        webSocketClient.Send(JsonConvert.SerializeObject(requestString));
    }
  1. Update url to “wss://stream.binance.com:9443/ws”
  2. Please print out requestString for review

that’s right !!! I didn’t see the brackets

“{“error”:{“code”:2,“msg”:“Invalid request: invalid type: string “{\“method\”: \“SUBSCRIBE\”, \“params\”: [\”!bookTicker\”], \“id\”: 1}”, expected internally tagged enum at line 1 column 71"}}"

This is more like a java coding problem. Just make sure you connect to “wss://stream.binance.com:9443/ws” and send a string converted from below JSON object:
{“method”: “SUBSCRIBE”,“params”:["!bookTicker"],“id”: 1}

(Still suspect why you put double curly brackets)