diff --git a/lib/cmds/blockchain/blockchain.js b/lib/cmds/blockchain/blockchain.js index 3bab4daa..ea492cdf 100644 --- a/lib/cmds/blockchain/blockchain.js +++ b/lib/cmds/blockchain/blockchain.js @@ -82,9 +82,9 @@ Blockchain.prototype.setupProxy = function(){ let ipcObject = new Ipc({ipcRole: 'client'}); proxy.serve(ipcObject, this.config.rpcHost, this.config.rpcPort, false); - // proxy.serve(ipcObject, this.config.wsHost, this.config.wsPort, true); + proxy.serve(ipcObject, this.config.wsHost, this.config.wsPort, true); this.config.rpcPort += 10; - //this.config.wsPort += 10; + this.config.wsPort += 10; } }; diff --git a/lib/core/proxy.js b/lib/core/proxy.js index 4e975d16..8cdacef4 100644 --- a/lib/core/proxy.js +++ b/lib/core/proxy.js @@ -7,9 +7,9 @@ exports.serve = function(ipc, host, port, ws){ let proxy = httpProxy.createProxyServer({ target: { host: host, - port: port + 10, - ws: ws - } + port: port + 10 + }, + ws: ws }); proxy.on('proxyRes', (proxyRes) => { @@ -32,7 +32,7 @@ exports.serve = function(ipc, host, port, ws){ delete commList[jsonO.id]; } } catch(e){ - // + // } }); }); @@ -54,13 +54,16 @@ exports.serve = function(ipc, host, port, ws){ } }); - if(ws){ - proxy.ws(req, res); - } else { + if(!ws){ proxy.web(req, res); } - }); + if(ws){ + server.on('upgrade', function (req, socket, head) { + proxy.ws(req, socket, head); + }); + } + server.listen(port); };