title: can't create a websocket sever correctly by express-ws middleware
body: <p>I'm writing a websocket server using node.js and express, and I use the express-ws middleware to help me. But the client can't connect the server.Below is my code.</p>
  
  <p>app.js:</p>
  
  <pre><code>var app = express();
  var expressWs = require("express-ws")(app);
  ...
  var webso = require("./routes/ws");
  app.use("/chat",webso);
  </code></pre>
  
  <p>routes/ws.js:</p>
  
  <pre><code>var express = require('express');
  var router = express.Router();
  
  router.ws("/",function(ws,req){
    console.log("socket from client")
    ws.on('message',function(msg){
      ws.send('back from node');
    })
  });
  module.exports=router;
  </code></pre>
  
  <p>the client:</p>
  
  <pre><code>wx.connectSocket({
          url:"ws://localhost:3000/chat",
          success(){
              console.log("success")
          },
          fail(){
              console.log("err")
          },
          complete(){
              console.log("done");
          }
      });
  </code></pre>
  
  <p>the client can't connect the websocket server:</p>
  
  <pre><code>asdebug.js:1 WebSocket connection to 'ws://localhost:3000/chat' failed: Connection closed before receiving a handshake response
  </code></pre>
  
  <p>I think something wrong I has made at the express server.I need your help.</p>