title: How to receive data more than 1024 bytes in nodejs sockets?
body: <p>Using the below code, I'm receiving data from devices. But if the device sends data more than 1024 bytes, the excess data got trimmed and I'm receiving only 1024 bytes. If there is any max read size that is restricted to 1024 bytes, how to increase it? </p>
  
  <p>I tried to check and increase current buffer size</p>
  
  <pre><code>socket.bufferSize  // result is 0
  socket.setBufferSize(8192); // error - setBufferSize is not a function
  </code></pre>
  
  <p>Below is socket code to receive data.</p>
  
  <pre><code>'use strict';
  import net from 'net';
  let logger = require('./logger')(module);
  /*
  * Socket Server.
  */
  const app = net.createServer(socketServer)
  /**
  * Socket Server Error.
  */
   .on('error', (error) =&gt; {
     if (error.code === 'EADDRINUSE') {
       /**
        * Address already in use.
        */
       logger.error(`port already in use: ${error}`);
     } else {
       /**
        * Other types of errors.
        */
       logger.error(`error in socket server: ${error}`);
     }
   })
   /**
    * Socket Server Close.
    */
   .on('close', () =&gt; {
     logger.error(`socket server closed`);
   });
  
  
  function socketServer(socket) {
  
   /**
    * @param {Number} milli-seconds - Trigger 'timeout' event if TCP 
    *   Socket is idle for given time.
    */
   socket.setTimeout(config.tcp_timeout);
   // socket.setBufferSize(8192) // gives error
  
   /**
    * @param {Buffer} deviceData - Device Data in Buffer format.
    */
   socket.on('data', (deviceData) =&gt; {
       logger.debug(deviceData);
   });
  
   socket.on('drain', () =&gt; {
     /**
      * Trigger when socket.write is complete.
      */
     // [ TODO: findout when this is executed. ]
     logger.info(`socket write is succesful`);
   });
  
   socket.on('timeout', () =&gt; {
     /**
      * [TODO: step if connection is idle.]
      */
     logger.warn(`${socket.imei} is idle`);
     // socket.destroy();
   });
  }
  
  export default app;
  </code></pre>