From 17a02c285f887523fafa20cccb5c74a19e5b0e5f Mon Sep 17 00:00:00 2001
From: Txiaozhe <txiaozhe@gmail.com>
Date: Thu, 25 Jul 2019 17:20:54 +0800
Subject: [PATCH 1/2] check server check.

---
 index.js |  4 ++++
 tests.js | 20 ++++++++++++++++++++
 2 files changed, 24 insertions(+)

diff --git a/index.js b/index.js
index 45a437e..80d24e8 100644
--- a/index.js
+++ b/index.js
@@ -83,6 +83,10 @@ module.exports = function(serverConfig, sharedConfig, clientStreamHandler){
       server = createSecureWebSocketServer(config.ssl, clientStreamHandler);
     }
 
+    if (!server) {
+      throw new Error('negative attach and unknow protocol');
+    }
+
     server._css_host = config.host;
     server._css_port = config.port;
 
diff --git a/tests.js b/tests.js
index 9097785..787859e 100644
--- a/tests.js
+++ b/tests.js
@@ -166,4 +166,24 @@ describe('create-stream-server', function(){
       });
     });
   });
+
+  it('should throw error if negative attach and unknow protocol', function(done) {
+    try {
+      var servers = css({
+        s1: {
+          attach: null,
+          protocol: 'unknow-protocol',
+          host: 'localhost',
+          port: 9010
+        }
+      }, function() {});
+    } catch(err) {
+      assert.deepStrictEqual(
+        err,
+        new Error('negative attach and unknow protocol'),
+        'negative attach and unknow protocol should error'
+      );
+      done();
+    }
+  })
 });

From 47477142effa958f8c298d406f5c04f70bd1a5d1 Mon Sep 17 00:00:00 2001
From: Txiaozhe <txiaozhe@gmail.com>
Date: Mon, 5 Aug 2019 12:09:35 +0800
Subject: [PATCH 2/2] Update index.js

---
 index.js | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/index.js b/index.js
index 80d24e8..8e069d5 100644
--- a/index.js
+++ b/index.js
@@ -81,9 +81,7 @@ module.exports = function(serverConfig, sharedConfig, clientStreamHandler){
       server = createWebSocketServer(clientStreamHandler);
     } else if(config.protocol == 'wss') {
       server = createSecureWebSocketServer(config.ssl, clientStreamHandler);
-    }
-
-    if (!server) {
+    } else {
       throw new Error('negative attach and unknow protocol');
     }