diff --git a/lib/WebSocket.js b/lib/WebSocket.js
index <HASH>..<HASH> 100644
--- a/lib/WebSocket.js
+++ b/lib/WebSocket.js
@@ -465,6 +465,7 @@ function initAsClient(address, options) {
   var isSecure = serverUrl.protocol === 'wss:' || serverUrl.protocol === 'https:';
   var httpObj = isSecure ? https : http;
   var port = serverUrl.port || (isSecure ? 443 : 80);
+  var auth = serverUrl.auth;
 
   // expose state properties
   this._isServer = false;
@@ -501,6 +502,12 @@ function initAsClient(address, options) {
       'Sec-WebSocket-Key': key
     }
   };
+
+  // If we have basic auth
+  if (auth) {
+    requestOptions.headers['authorization'] = new Buffer('Basic ' + auth).toString('base64');
+  }
+
   if (options.value.protocol) {
     requestOptions.headers['Sec-WebSocket-Protocol'] = options.value.protocol;
   }
[fix] add ability to handle basic auth