Skip to content

Commit

Permalink
upd
Browse files Browse the repository at this point in the history
  • Loading branch information
ttodua committed Apr 24, 2024
1 parent a3d3779 commit 6e910fe
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions ts/src/pro/test/Exchange/test.proxies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,21 @@ async function testWsProxy (exchange: Exchange, skippedProperties: object) {
exchange.wsProxy = 'http://' + testVpsServerIp + ':8002'; // "wsProxy" or "wssProxy" (depending on your proxy protocol)
exchange.handleMessage = ws_helper_callback; // todo for PHP: specifically this custom example does not work in PHP to retrieve the target message, however proxies do work in PHP for websockets independently from this example
const demoServerUrl = 'ws://' + testVpsServerIp + ':9876';
exchange.options['tempWatchPromise'] = exchange.watch (demoServerUrl, 'test', 'test');
const promise = exchange.watch (demoServerUrl, 'ws_proxy_test', 'ws_proxy_test');
// reset the instance property
testSharedMethods.setProxyOptions (exchange, skippedProperties, proxyUrl, httpProxy, httpsProxy, socksProxy);
return await exchange.options['tempWatchPromise'];
return await promise;
}

function ws_helper_callback (client, message) {
const method = 'wsProxy';
const testVpsServerIp = '5.75.153.75';
// message like: { msg: "hi from test server", your_ip: "::ffff:5.75.153.75" }
try {
if ('your_ip' in message) {
let ipString = message['your_ip'];
ipString = ipString.replace ('::ffff:', '');
assert (ipString === testVpsServerIp, method + ' test failed. Returned response is ' + ipString + ' while it should be "' + testVpsServerIp + '"');
console.log ('WS proxy test finished');
client.resolve ();
}
}
catch (e) {
console.log (e);
if ('your_ip' in message) {
let ipString = message['your_ip'];
ipString = ipString.replace ('::ffff:', '');
assert (ipString === testVpsServerIp, method + ' test failed. Returned response is ' + ipString + ' while it should be "' + testVpsServerIp + '"');
client.resolve (null, 'ws_proxy_test');
}
}

Expand Down

0 comments on commit 6e910fe

Please sign in to comment.