fix: simulator proxy with ws

This commit is contained in:
Anthony Laibe 2019-01-23 13:00:41 +00:00
parent 2613e6d683
commit 5968eef349
2 changed files with 9 additions and 5 deletions

View File

@ -86,6 +86,10 @@ class Simulator {
if(useProxy){
let ipcObject = new Ipc({ipcRole: 'client'});
if (this.blockchainConfig.wsRPC) {
return new Proxy(ipcObject).serve(host, port, true, this.blockchainConfig.wsOrigins, []);
}
new Proxy(ipcObject).serve(host, port, false);
}
}

View File

@ -127,7 +127,9 @@ function pingEndpoint(host, port, type, protocol, origin, callback) {
};
const handleSuccess = (req, closeMethod, event) => {
req.once(event, () => { handleEvent(req, closeMethod); });
req.once(event, () => {
handleEvent(req, closeMethod);
});
};
const handleRequest = (req, closeMethod, event) => {
@ -136,10 +138,8 @@ function pingEndpoint(host, port, type, protocol, origin, callback) {
};
if (type === 'ws') {
const req = new (require('ws'))(
`${protocol === 'https' ? 'wss' : 'ws'}://${_host}:${port}/`,
origin ? {origin} : {}
);
const url = `${protocol === 'https' ? 'wss' : 'ws'}://${_host}:${port}/`;
const req = new (require('ws'))(url, origin ? {origin} : {});
handleRequest(req, 'close', 'open');
} else {
const headers = origin ? {Origin: origin} : {};