mirror of https://github.com/embarklabs/embark.git
fix: simulator proxy with ws
This commit is contained in:
parent
2613e6d683
commit
5968eef349
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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} : {};
|
||||
|
|
Loading…
Reference in New Issue