Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot catch "Already logged on, cannot log on again" error #481

Closed
thecatontheflat opened this issue Apr 10, 2024 · 0 comments
Closed

Cannot catch "Already logged on, cannot log on again" error #481

thecatontheflat opened this issue Apr 10, 2024 · 0 comments
Labels

Comments

@thecatontheflat
Copy link

Describe the bug

The Already logged on, cannot log on again error is thrown when attempting to logOn() after proxy timeout.
The issue started happening regularly during the Steam outages after we upgraded the node-steam-user package

Relevant bits from the code.

Initiating the user:

	this.steamUser = new SteamUser({
		httpProxy: proxyUrl,
		webCompatibilityMode: true,
		machineIdType: EMachineIDType?.AlwaysRandom || 2,
		autoRelogin: true,
	});

        this.steamUser.on('disconnected', (eresult, msg) => {
	        console.log('Received disconnected event', eresult, msg);
        });

        this.steamUser.on('error', (error) => {

                // Steam ID is set, meaning it was a Steam induced disconnect event, so we exit
                if (this.steamUser?.steamID) return;

	       console.error('Steam client disconnected, retrying connection', error.message);
		setTimeout(() => {
			this.steamUser.logOn(this.credential);
		}, 60 * 1000); // backing off for 1 minute
        });

At some point (usually happens during Steam downtime) the user gets disconnected (expected):

Received disconnected event 3 NoConnection

Autorelogin attempts to reconnect, which is expected too.
This results in the following log message:

Steam client disconnected, retrying connection Proxy connection timed out

Then shortly after the following error is thrown:

Unhandled Promise Rejection Promise {
  <rejected> Error: Already attempting to log on, cannot log on again
      at SteamUser.logOn (/var/www/app/node_modules/steam-user/components/09-logon.js:49:32)
      at Timeout._onTimeout (/var/www/app/dist/bot-client.js:233:28)
      at listOnTimeout (internal/timers.js:557:17)
      at processTimers (internal/timers.js:500:7)
} Error: Already attempting to log on, cannot log on again
    at SteamUser.logOn (/var/www/app/node_modules/steam-user/components/09-logon.js:49:32)
    at Timeout._onTimeout (/var/www/app/dist/bot-client.js:233:28)
    at listOnTimeout (internal/timers.js:557:17)
    at processTimers (internal/timers.js:500:7)

My current workaround is to check for this internal property on the SteamUser object, but it smells funny.

if (this.steamUser['_connecting']) return

I was able to reproduce this error by setting an extremely low proxy timeout (1ms) here:
https://github.com/DoctorMcKay/node-stdlib/blob/master/src/lib/http/proxyagent.ts#L41

My guess is that the proxy timeout aren't being handled in the same way as vanilla WS timeouts, because they emit an error instead of timeout.

Versions

node v14
steam-user 5.0.8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant