How to get data from SG by WebSocket changes-feed with cookies

I am using WebSocket to get changes data from SG by NodeJS, follow demo works fine:

var WebSocket = require('ws');
var cookie = require('cookie');

var ws = new WebSocket(
        'headers': {
            'Cookie': cookie.serialize('SyncGatewaySession', 'e81fca4cc9ff5a80676ea7a385a6a30934260188')

ws.on('open', function open() {
  ws.send('{"since": 0, "include_docs": true,"limit":50}');

  ws.on('message', function incoming(message) {
    console.log('received: %s', message);

And the Sg logs shows as following:

2017-03-23T21:07:57.963+06:00 HTTP:  #001: GET /sg/_changes?feed=websocket  (as f552e90a-afd6-494f-acd7-36873d222f73)
2017-03-23T21:07:57.964+06:00 HTTP+: #001:     --> 101 Upgraded to WebSocket protocol  (0.0 ms)
2017-03-23T21:07:57.970+06:00 Changes+: Int sequence multi changes feed...
2017-03-23T21:07:57.970+06:00 Changes: MultiChangesFeed({*}, {Since:0 Limit:50 Conflicts:false IncludeDocs:true Wait:true Continuous:true Terminator:0xc82049c720 HeartbeatMs:0 TimeoutMs:300000 ActiveOnly:false}) ...   (to f552e90a-afd6-494f-acd7-36873d222f73)

but when I deploy the code on my web application running on,
I got the following error

2017-03-23T21:54:49.110+06:00 HTTP:  #003: GET /sg/_changes?feed=websocket
2017-03-23T21:54:49.110+06:00 HTTP: #003:     --> 401 login required (0.4 ms)

It looks like the cookie header is not being sent.

The fastest way to validate would probably be to use a packet capture tool (e.g wireshark) and compare the NodeJS and Browser requests/responses.

yes, I fixed the issue by using native WebSocket client code.
it is not SG issue.
thank you.