diff --git a/lib/WebSocket.js b/lib/WebSocket.js
index <HASH>..<HASH> 100644
--- a/lib/WebSocket.js
+++ b/lib/WebSocket.js
@@ -641,20 +641,12 @@ function establishConnection(ReceiverClass, SenderClass, socket, upgradeHead) {
     self._receiver.add(data);
   }
   var dataHandler = firstHandler;
-  process.nextTick(function () {
-    // It could happen that a `data` event is
-    // fired even before our readyState is set
-    // to WebSocket.OPEN, so we start listening
-    // to the event on the next tick
-    socket.on('data', dataHandler);
-
-    // if data was passed along with the http upgrade,
-    // this will schedule a push of that on to the receiver.
-    // this has to be done on next tick, since the caller
-    // hasn't had a chance to set event handlers on this client
-    // object yet.
-    firstHandler();
-  );
+  // if data was passed along with the http upgrade,
+  // this will schedule a push of that on to the receiver.
+  // this has to be done on next tick, since the caller
+  // hasn't had a chance to set event handlers on this client
+  // object yet.
+  process.nextTick(firstHandler);
 
   // receiver event handlers
   self._receiver.ontext = function (data, flags) {
@@ -692,6 +684,8 @@ function establishConnection(ReceiverClass, SenderClass, socket, upgradeHead) {
   });
   this.readyState = WebSocket.OPEN;
   this.emit('open');
+
+  socket.on('data', dataHandler);
 }
 
 function startQueue(instance) {
another approach for fixing the race condition. moved data listener to the end of the function