title: Binance TIMESTAMP ERROR (Timestamp for this request is outside of the recvWindow. M 1)
body: <p>I'm using binance broker api, when executing my code.</p>
  <p><em>I got this error :</em>
  <strong>data: {
  code: -1021,enter code here
  msg: 'Timestamp for this request is outside of the recvWindow.'
  }</strong></p>
  <p><em>Then I have used binance server timestamp and get another error :</em>
  <strong>data: { code: -1022, msg: 'Signature for this request is not valid.' }</strong></p>
  <pre><code>----- My sample code -------
  
  'use strict'
  
  //Modules
  const crypto = require('crypto');
  const axios = require('axios');
  const moment = require('moment');
  const keys = require('./config/keys');
  
  
  //Keys
  const apiKey = keys.keys.apiKey;
  
  async function api_call(config){
    var response  = {}
    try {
      response = await axios(config);
      response =  {
        error: false,
        data : response.data
      }
    } catch (error) {
      response =  { 
        error: true,
        data : error
      }
    }
    return response;
  }
  
  
  async function get_binance_server_time(recvWindow=50000){
    var timestamp = moment().unix();
    var serverTime = 0;
  
    var config = {
      method: 'get',
      url: `https://api.binance.com/api/v3/time`,
      headers: { 
        'Content-Type': 'application/json', 
        'X-MBX-APIKEY': apiKey 
      }
    };  
    var response = await api_call(config);
  
    if(response.error){
      response.data = {
        serverTime : serverTime
      }
    }
    serverTime = response.data.serverTime
  
    console.log(timestamp);
    console.log(response.data.serverTime);
  
    if (timestamp &lt; (serverTime + 1000) &amp;&amp; (serverTime - timestamp) &lt;= recvWindow) {
      console.log(&quot;process&quot;);
    } else {
      console.log(&quot;Rejected&quot;);
    }
    return serverTime;
  }
  
  
  async function get_broker_account_information( _signature = null){
  
    // Make the api call here
    var serverTime  = await get_binance_server_time();
    var _timestamp = serverTime;
  
    const query_string = `timestamp=${_timestamp}`;
    const recvWindow = 50000
    const signature = crypto.createHmac('sha256', apiKey).update(query_string).digest('hex')
  
    var config = {
      method: 'get',
      url: `https://api.binance.com/sapi/v1/broker/info?timestamp=${_timestamp}&amp;signature=${signature}&amp;recvWindow=${recvWindow}`,
      headers: { 
        'Content-Type': 'application/json', 
        'X-MBX-APIKEY': apiKey 
      }
    };  
    
    var response = await api_call(config)
    console.log(response.data);
    return response;
  }
  
  
  
  
  // create_sub_account()
  get_broker_account_information()
  // get_binance_server_time()
  
  </code></pre>