use latest ws
This commit is contained in:
parent
1a84c1db10
commit
4f53821a2c
14
client.js
14
client.js
|
@ -42,17 +42,19 @@ function getConnection(opts, verbs, mySocket, retry) {
|
||||||
// TODO how to include path and such?
|
// TODO how to include path and such?
|
||||||
// http://unix:/absolute/path/to/unix.socket:/request/path
|
// http://unix:/absolute/path/to/unix.socket:/request/path
|
||||||
// https://github.com/websockets/ws/issues/236
|
// https://github.com/websockets/ws/issues/236
|
||||||
var address = require('url').parse('ws+unix:' + opts.sock);
|
|
||||||
var ws;
|
var ws;
|
||||||
address.pathname = opts.sock;
|
var pathname = '/' + (require('cluster').worker||{}).id + '/' + opts.ipcKey;
|
||||||
address.path = '/' + (require('cluster').worker||{}).id + '/' + opts.ipcKey;
|
var queryparams = {
|
||||||
address.query = {
|
|
||||||
ipcKey: opts.ipcKey
|
ipcKey: opts.ipcKey
|
||||||
, ipc_key: opts.ipcKey
|
, ipc_key: opts.ipcKey
|
||||||
, worker_id: (require('cluster').worker||{}).id
|
, worker_id: (require('cluster').worker||{}).id
|
||||||
};
|
};
|
||||||
address.path += '?' + require('querystring').stringify(address.query);
|
var search = require('querystring').stringify(queryparams);
|
||||||
ws = new WebSocket(address);
|
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) {
|
ws.on('error', function (err) {
|
||||||
console.error('[ERROR] ws connection failed, retrying');
|
console.error('[ERROR] ws connection failed, retrying');
|
||||||
|
|
|
@ -26,6 +26,6 @@
|
||||||
"homepage": "https://github.com/coolaj86/sqlite3-cluster#readme",
|
"homepage": "https://github.com/coolaj86/sqlite3-cluster#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"sqlite3": "^3.0.9",
|
"sqlite3": "^3.0.9",
|
||||||
"ws": "^0.7.2"
|
"ws": "^2.3.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue