mirror of
https://github.com/Xahau/xahau.js.git
synced 2026-08-23 08:30:51 +00:00
Fix support for proxy credentials in proxy URL and fix error when there are more than 10 outstanding requests
This commit is contained in:
@@ -15,6 +15,7 @@ function isStreamMessageType(type) {
|
||||
class Connection extends EventEmitter {
|
||||
constructor(url, options = {}) {
|
||||
super();
|
||||
this.setMaxListeners(Infinity);
|
||||
this._url = url;
|
||||
this._trace = options.trace;
|
||||
if (this._trace) {
|
||||
@@ -111,8 +112,10 @@ class Connection extends EventEmitter {
|
||||
const proxyOptions = parseURL(proxyURL);
|
||||
proxyOptions.secureEndpoint = (parsedURL.protocol === 'wss:');
|
||||
proxyOptions.secureProxy = (proxyOptions.protocol === 'https:');
|
||||
proxyOptions.auth = proxyAuthorization;
|
||||
if (trustedCertificates) {
|
||||
if (proxyAuthorization !== undefined) {
|
||||
proxyOptions.auth = proxyAuthorization;
|
||||
}
|
||||
if (trustedCertificates !== undefined) {
|
||||
proxyOptions.ca = trustedCertificates;
|
||||
}
|
||||
let HttpsProxyAgent;
|
||||
@@ -127,7 +130,11 @@ class Connection extends EventEmitter {
|
||||
const base64 = new Buffer(authorization).toString('base64');
|
||||
options.headers = {Authorization: `Basic ${base64}`};
|
||||
}
|
||||
return new WebSocket(url, options);
|
||||
const websocket = new WebSocket(url, options);
|
||||
// we will have a listener for each outstanding request,
|
||||
// so we have to raise the limit (the default is 10)
|
||||
websocket.setMaxListeners(Infinity);
|
||||
return websocket;
|
||||
}
|
||||
|
||||
connect() {
|
||||
|
||||
Reference in New Issue
Block a user