unhandled proxy ECONNREFUSED
Error: connect ECONNREFUSED xxx.xxx.xxx.xxx:xxxx
at Object.exports._errnoException (util.js:1022:11)
at exports._exceptionWithHostPort (util.js:1045:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1087:14)
Is it possible to somehow handle this error?? If the proxy server doesnt respond the client crashes.
my code:
this.steamclient = new steam.CMClient();
this.steamclient.setHttpProxy(proxyUrl);
this.client = new SteamUser(this.steamclient);
also
this.proxifiedRequest = request.defaults({'proxy': proxyUrl});
this.community = new SteamCommunity({request: this.proxifiedRequest});
this.client.on('webSession', function(sessionID, cookies){
self.community.setCookies(cookies);
self.manager.setCookies(cookies, function(err) {});
self.community.startConfirmationChecker(15000, self.identitySecret);
});
Are you handling the error event on SteamUser?
this.client.on('error', function (err) {
console.log("Steam Client error: ");
console.log(err);
});
doesnt help
I'm pretty sure socket hang up error is connected to this, both are caused by malfunctioning proxy. In my case the flow is:
-
socket hang upthrows up the script - Process manager restarts the script
-
ECONNREFUSEDis thrown after theSteamUser.logOnis called
The problem is obviously caused by the proxy which drops / refuses connection. Temporary solution is to fix the proxy service, although it would be nice if we could handle it properly.
Error: socket hang up
at createHangUpError (_http_client.js:254:15)
at Socket.socketOnEnd (_http_client.js:346:23)
at emitNone (events.js:91:20)
at Socket.emit (events.js:185:7)
at endReadableNT (_stream_readable.js:974:12)
at _combinedTickCallback (internal/process/next_tick.js:74:11)
at process._tickDomainCallback [as _tickCallback] (internal/process/next_tick.js:122:9)
Handlers set as following:
_client.on('error', handleClientError);
_user.on('error', handleUserError);
I just noticed the handler (currently can't say which one, as it was logging only error.toString()) catched Error: connect ECONNREFUSED xxx.xxx.xxx.xxx:xxxx just before the app threw up with the same error (exactly the one encountered by @Freaders).
In cm_client.js#L105 TCPConnection is used before error handler is set, may be the reason of ECONNREFUSED, the comment says error should be passed as the callback first argument, although it's the code from before proxy update.
i have proxies from third party provider so i cannot really "fix" them.. so i can use the steamclient.on('error', handleClientError); to catch the error and then reconnect the acc again to the steam?
You can get better proxies, that doesn't refuse the connection.
The error is being thrown despite handling error event on the client. I'm hoping that the reason for this is exposed in my previous comment, I'll check this out for sure after I'm done reading _http_client.js finding a solution for socket hang up :)
could you recommend any proxy provider? thanks
Moving error handler before the callback worked.
Tested on ETIMEDOUT, which was throwing before exactly like ECONNREFUSED and is easier to reproduce.
Moving the error outside the callback should be safe, as the object gets deleted in CMClient._disconnected upon connection failure.
Test code:
const SteamClient = require('steam-client');
const SteamUser = require('steam-user');
const client = new SteamClient.CMClient();
client.setHttpProxy('http://timeouting-proxy');
const user = new SteamUser(client);
client.on('error', (...data) => console.log('client-error', ...data));
client.on('debug', (...data) => console.log('client-debug', ...data));
user.on('error', (...data) => console.log('user-error', ...data));
user.logOn({ accountName: 'XXX', password: 'XXX' });
That works! Any advice how to properly handle this? Thank you very much.
/bot/node_modules/steam-user/components/web.js:9
throw new Error("Cannot log onto steamcommunity.com without first being connected to Steam network");
^
Error: Cannot log onto steamcommunity.com without first being connected to Steam network
at SteamUser.webLogOn (/bot/node_modules/steam-user/components/web.js:9:9)
at Timeout._onTimeout (/bot/bot.js:462:30)
at ontimeout (timers.js:365:14)
at tryOnTimeout (timers.js:237:5)
at Timer.listOnTimeout (timers.js:207:5)
error: Forever detected script exited with code: 1