title: Unable to get the socket data through binance Websockets
body: <p>This is my client-side code base. It is working with one of the exchange websockets but not working with this websocket. Any suggestions?</p>
  
  <p>websocket reference: <a href="https://github.com/binance-exchange/binance-official-api-docs/blob/master/web-socket-streams.md" rel="nofollow noreferrer">https://github.com/binance-exchange/binance-official-api-docs/blob/master/web-socket-streams.md</a></p>
  
  <pre><code>import React, { Component, createContext } from "react";
  
  export const Contx = createContext();
  
  export class ConProvider extends Component {
    state = {
      coins: [],
      digCoin: [],
      sou: [],
      passSocket: undefined
    };
  
    componentDidMount() {
      this.socketCall();  
    }
  
    socketCall = () =&gt; {
      var ws = new WebSocket("wss://stream.binance.com:9443");
      var msg = {
        "method": "SUBSCRIBE",
        "params": "btcusdt@depth",
        "id": 1
      };
  
      ws.onopen = () =&gt; {
        ws.send(msg);
      };
  
      ws.onmessage = e =&gt; {
        const value = e.data;
        this.setState({
          coins: value
        });
      };
  
      this.setState({
        passSocket: ws
      });
    };
  
    socketClose = () =&gt; {
      var wss = this.state.passSocket;
      wss.close();
    };
  
    render() {
      console.log(this.state.coins);
  
      // console.log(this.state.coins)
      return (
        &lt;Contx.Provider
          value={{
            ...this.state,
            socketCall: this.socketCall,
            socketClose: this.socketClose
          }}
        &gt;
          {this.props.children}
        &lt;/Contx.Provider&gt;
      );
    }
  }
  </code></pre>