From 4f53821a2ccdb2f2439add4d7c29e3dedc1397a7 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Tue, 9 May 2017 11:37:46 -0600 Subject: [PATCH] use latest ws --- client.js | 14 ++++++++------ package.json | 2 +- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/client.js b/client.js index dedd5a8..3a38947 100644 --- a/client.js +++ b/client.js @@ -42,17 +42,19 @@ function getConnection(opts, verbs, mySocket, retry) { // TODO how to include path and such? // http://unix:/absolute/path/to/unix.socket:/request/path // https://github.com/websockets/ws/issues/236 - var address = require('url').parse('ws+unix:' + opts.sock); var ws; - address.pathname = opts.sock; - address.path = '/' + (require('cluster').worker||{}).id + '/' + opts.ipcKey; - address.query = { + var pathname = '/' + (require('cluster').worker||{}).id + '/' + opts.ipcKey; + var queryparams = { ipcKey: opts.ipcKey , ipc_key: opts.ipcKey , worker_id: (require('cluster').worker||{}).id }; - address.path += '?' + require('querystring').stringify(address.query); - ws = new WebSocket(address); + var search = require('querystring').stringify(queryparams); + var wspath = 'ws+unix://' + opts.sock + ':' + pathname + '?' + search; + // https://github.com/websockets/ws/blob/master/doc/ws.md#unix-domain-sockets + // ws+unix:///absolule/path/to/uds_socket:/pathname?search_params + console.log('ws connect', wspath); + ws = new WebSocket(wspath); ws.on('error', function (err) { console.error('[ERROR] ws connection failed, retrying'); diff --git a/package.json b/package.json index c5fc936..87846c2 100644 --- a/package.json +++ b/package.json @@ -26,6 +26,6 @@ "homepage": "https://github.com/coolaj86/sqlite3-cluster#readme", "dependencies": { "sqlite3": "^3.0.9", - "ws": "^0.7.2" + "ws": "^2.3.1" } }