LinkerH Posted August 13, 2023 Report Posted August 13, 2023 Upon launching my program, the first login and message sending work perfectly fine. However, when I start the game from another location, it triggers an error in my program, and I receive a Debug event received: Logged off: LoggedInElsewhere' message. After attempting to log in again and successfully doing so, when I try to send a message, I encounter the issue where I receive the 'Debug event received: Dropping outgoing message 5505 because we're not logged on.' The complete debug information is as follows: The first time: Debug event received: [T1] Connecting to TCP CM: 103.10.125.148:27018 Debug event received: [T1] TCP connection established Debug event received: [T1] Handled message: ChannelEncryptRequest Debug event received: Channel encrypt request: protocol 1, universe 1, nonce ab0bdc3141281b723f648d9944c03296, 0 remain ng bytes Debug event received: Sending message: ChannelEncryptResponse Debug event received: [T1] Handled message: ChannelEncryptResult Debug event received: Node version is new enough for steam-session; performing new auth Debug event received: Sending message: ClientHello Debug event received: Sending message: Authentication.GetPasswordRSAPublicKey#1 Debug event received: [T1#1] Handled message: Authentication.GetPasswordRSAPublicKey#1_Response Debug event received: Sending message: Authentication.BeginAuthSessionViaCredentials#1 Debug event received: [T1#2] Handled message: Authentication.BeginAuthSessionViaCredentials#1_Response Debug event received: [steam-session] Debug event received: [steam-session] Debug event received: [steam-session] Debug event received: Sending message: Authentication.UpdateAuthSessionWithSteamGuardCode#1 Debug event received: [T1#3] Handled message: Authentication.UpdateAuthSessionWithSteamGuardCode#1_Response Debug event received: Sending message: Authentication.PollAuthSessionStatus#1 Debug event received: [T1#4] Handled message: Authentication.PollAuthSessionStatus#1_Response Debug event received: [steam-session] Debug event received: New auth succeeded in 2673 ms Debug event received: Sending message: ClientLogon Debug event received: [T1] Got incomplete message; expecting 8800 more bytes Debug event received: [T1#5] Unhandled message: ClientServersAvailable Debug event received: [T1#5] Unhandled message: ClientServersAvailable Debug event received: [T1#5] Handled message: ClientLogOnResponse (OK) Debug event received: Handle logon response (OK) Debug event received: Sending message: ClientRequestItemAnnouncements Debug event received: Sending message: ClientRequestCommentNotifications Debug event received: Sending message: ClientChatRequestOfflineMessageCount Debug event received: Sending message: Authentication.GenerateAccessTokenForApp#1 Debug event received: [T1#5] Handled message: ClientAccountInfo Debug event received: [T1#5] Handled message: ClientEmailAddrInfo Debug event received: [T1#5] Handled message: ClientFriendsList Debug event received: Sending message: ClientRequestFriendData Debug event received: [T1#5] Handled message: ClientPlayerNicknameList Debug event received: [T1#5] Handled message: ClientLicenseList Debug event received: [T1#5] Handled message: ClientUpdateGuestPassesList Debug event received: [T1#5] Handled message: ClientWalletInfoUpdate Debug event received: [T1#5] Handled message: ClientGameConnectTokens Debug event received: Received 10 game connect tokens. Had 0 tokens. Debug event received: [T1#5] Handled message: ClientIsLimitedAccount Debug event received: [T1#5] Unhandled message: ClientRequestedClientStats Debug event received: [T1#5] Handled message: ClientPlayingSessionState Debug event received: [T1#5] Handled message: ClientVACBanStatus Debug event received: Sending 730 GC message 4006 Debug event received: Sending message: ClientToGC Debug event received: [T1#23] Handled message: ClientClanState Debug event received: [T1#24] Handled message: ClientClanState Debug event received: [T1#25] Handled message: ClientClanState Debug event received: [T1#26] Handled message: ClientClanState Debug event received: [T1#27] Handled message: ClientClanState Debug event received: [T1#28] Handled message: ClientClanState Debug event received: [T1#29] Handled message: ClientClanState Debug event received: [T1] TCP connection ended Debug event received: [T1#30] Handled message: ClientLoggedOff Debug event received: Logged off: LoggedInElsewhere Debug event received: Disconnecting without sending logoff Debug event received: [T1] Ending connection and removing all listeners error:Error: LoggedInElsewhere Logon again: Debug event received: Error reading file machineAuthToken.xxx.txt: ENOENT: no such file or directory Debug event received: [T2] Connecting to TCP CM: 155.133.245.36:27018 Debug event received: [T2] TCP connection established Debug event received: [T2] Handled message: ChannelEncryptRequest Debug event received: Channel encrypt request: protocol 1, universe 1, nonce 154748b6c7a8ab0b0838216a0cf26838, 0 remain ng bytes Debug event received: Sending message: ChannelEncryptResponse Debug event received: [T2] Handled message: ChannelEncryptResult Debug event received: Node version is new enough for steam-session; performing new auth Debug event received: Sending message: ClientHello Debug event received: Sending message: Authentication.GetPasswordRSAPublicKey#1 Debug event received: [T2#1] Handled message: Authentication.GetPasswordRSAPublicKey#1_Response Debug event received: Sending message: Authentication.BeginAuthSessionViaCredentials#1 Debug event received: [T2#2] Handled message: Authentication.BeginAuthSessionViaCredentials#1_Response Debug event received: [steam-session] Debug event received: [steam-session] Debug event received: [steam-session] Debug event received: Sending message: Authentication.UpdateAuthSessionWithSteamGuardCode#1 Debug event received: [T2#3] Handled message: Authentication.UpdateAuthSessionWithSteamGuardCode#1_Response Debug event received: Sending message: Authentication.PollAuthSessionStatus#1 Debug event received: [T2#4] Handled message: Authentication.PollAuthSessionStatus#1_Response Debug event received: [steam-session] Debug event received: New auth succeeded in 2350 ms Debug event received: Sending message: ClientLogon Debug event received: [T2] Got incomplete message; expecting 8784 more bytes Debug event received: [T2#5] Unhandled message: ClientServersAvailable Debug event received: [T2#5] Unhandled message: ClientServersAvailable Debug event received: [T2#5] Handled message: ClientLogOnResponse (OK) Debug event received: Handle logon response (OK) Debug event received: Sending message: ClientRequestItemAnnouncements Debug event received: Sending message: ClientRequestCommentNotifications Debug event received: Sending message: ClientChatRequestOfflineMessageCount Debug event received: Sending message: Authentication.GenerateAccessTokenForApp#1 Debug event received: [T2#5] Handled message: ClientAccountInfo Debug event received: [T2#5] Handled message: ClientEmailAddrInfo Debug event received: [T2#5] Handled message: ClientFriendsList Debug event received: Sending message: ClientRequestFriendData Debug event received: [T2#5] Handled message: ClientPlayerNicknameList Debug event received: [T2#5] Handled message: ClientLicenseList Debug event received: [T2#5] Handled message: ClientUpdateGuestPassesList Debug event received: [T2#5] Handled message: ClientWalletInfoUpdate Debug event received: [T2#5] Handled message: ClientGameConnectTokens Debug event received: Received 10 game connect tokens. Had 0 tokens. Debug event received: [T2#5] Handled message: ClientIsLimitedAccount Debug event received: [T2#5] Unhandled message: ClientRequestedClientStats Debug event received: [T2#5] Handled message: ClientPlayingSessionState Debug event received: [T2#5] Handled message: ClientVACBanStatus Debug event received: [T2#9] Unhandled message: PlayerClient.NotifyLastPlayedTimes#1 Debug event received: [T2#10] Handled message: ClientPlayingSessionState Debug event received: [T2#10] Handled message: ClientGameConnectTokens Debug event received: Received 1 game connect tokens. Had 10 tokens. Debug event received: Sending 730 GC message 4006 Debug event received: Sending message: ClientToGC Debug event received: [T2#11] Unhandled message: ClientServersAvailable Debug event received: [T2#12] Unhandled message: ClientServiceCall Debug event received: [T2] Got incomplete message; expecting 7904 more bytes Debug event received: [T2] Got incomplete message; expecting 7904 more bytes Debug event received: Enqueued incoming message; queue size is now 1 Debug event received: [T2#13] Handled message: ClientFromGC Debug event received: Received 730 GC message 4004 Received message 4004 from GC 730 with 42978 bytes Debug event received: Sending message: ClientToGC Debug event received: [T2#14] Handled message: ClientFromGC Debug event received: Received 730 GC message 9173 Debug event received: [T2#14] Handled message: ClientFromGC Debug event received: Received 730 GC message 9110 Debug event received: [T2#14] Handled message: ClientFromGC Debug event received: Received 730 GC message 9194 Debug event received: [T2#14] Handled message: ClientFromGC Debug event received: Received 730 GC message 9173 Debug event received: [T2#15] Handled message: ClientMicroTxnAuthRequest Debug event received: Dropping outgoing message 5505 because we're not logged on. Upon triggering an error and subsequently logging in again, the logs indicate successful login and successful message transmission. However, when attempting to send messages afterwards, it displays as not logged in. What could be the reason behind this? In the second time ,the property of steamID is null. But the wallet and other properties are correct. Quote
Dr. McKay Posted August 13, 2023 Report Posted August 13, 2023 I don't know why this would happen. Do you have any code that can reliably reproduce this so I can try to debug it on my end? Quote
LinkerH Posted August 13, 2023 Author Report Posted August 13, 2023 (edited) 1 hour ago, Dr. McKay said: I don't know why this would happen. Do you have any code that can reliably reproduce this so I can try to debug it on my end? class steam { private client; constructor() { this.client = new SteamUser(); this.init(); } public async login(opt){ return new Promise(resolve => { this.client.logOn(opt); this.client.once('loggedOn', ()=>{ this.client.gamesPlayed(730,true); console.log("Login success:" + opt.accountName); console.log("SteamID in Login step:" + this.client.steamID); resolve(true); }) }) } private init(){ this.client._handlerManager.add(EMsg.ClientWalletInfoUpdate, (body) =>{ console.log("ClientWalletInfoUpdate:" + body); console.log("SteamID in wallet step:" + this.client.steamID) }); this.client.on('error',(error) =>{ console.log("error:" + error) }) } } async function testSteamID(){ let client = new steam(); await client.login({ "accountName": "accountName", "password": "password", "twoFactorCode": "twoFactorCode" }) } setInterval(()=>testSteamID(),30000); The output is : Login success:accoutName SteamID in Login step:765xxxxxxxxxxxxx ClientWalletInfoUpdate:[object Object] SteamID in wallet step:765xxxxxxxxxxxxx /* In this 30s , we need to run csgo,and close it */ error:Error: LoggedInElsewhere Login success:accoutName SteamID in Login step:765xxxxxxxxxxxxx ClientWalletInfoUpdate:[object Object] SteamID in wallet step:null In this 30s , we need to run csgo,and close it Edited August 13, 2023 by LinkerH Quote
Dr. McKay Posted August 13, 2023 Report Posted August 13, 2023 Why are you directly calling _handlerManager.add? Anything prefixed with an underscore is internal and not meant to be used directly. This is why you're experiencing the problem that you are. When testSteamID() is called for the second time, you create a new steam class instance. But your custom ClientWalletInfoUpdate handler still exists and still references your first steam class instance, which references your first SteamUser instance. There's no need to create a whole new SteamUser instance every time you need to reconnect. Just call logOn again. Another problem in your code is your once handler for loggedOn. loggedOn will be called potentially multiple times without an error event in between, e.g. if your connection to Steam temporarily drops and automatically reconnects. This is why logOn doesn't return a promise in the first place. Quote
LinkerH Posted August 14, 2023 Author Report Posted August 14, 2023 6 hours ago, Dr. McKay said: Why are you directly calling _handlerManager.add? Anything prefixed with an underscore is internal and not meant to be used directly. This is why you're experiencing the problem that you are. When testSteamID() is called for the second time, you create a new steam class instance. But your custom ClientWalletInfoUpdate handler still exists and still references your first steam class instance, which references your first SteamUser instance. There's no need to create a whole new SteamUser instance every time you need to reconnect. Just call logOn again. Another problem in your code is your once handler for loggedOn. loggedOn will be called potentially multiple times without an error event in between, e.g. if your connection to Steam temporarily drops and automatically reconnects. This is why logOn doesn't return a promise in the first place. Thank you very much for your prompt response. I've reduced the creation of SteamUser instances, and now the code works correctly. I have some messages that require custom handling, but I can't find a public method to set up handlerManage. How should I go about adding custom handler in a reasonable way? Quote
Dr. McKay Posted August 15, 2023 Report Posted August 15, 2023 On 8/13/2023 at 8:47 PM, LinkerH said: Thank you very much for your prompt response. I've reduced the creation of SteamUser instances, and now the code works correctly. I have some messages that require custom handling, but I can't find a public method to set up handlerManage. How should I go about adding custom handler in a reasonable way? This is not officially supported and is liable to break at any time. If you need to handle a message that isn't already directly supported in SteamUser, and you don't want to fork the project and submit the changes as a pull request, then you should call _handlerManager.add as you are in the code above, but instead of passing an arrow function as the handler method, pass a regular anonymous function. Then, in the handler function, this will refer to the SteamUser instance that received the message (see how it's done in the module here). You will also need to handle protobuf encoding and decoding yourself if the messages aren't already mapped in 03-messages.js. Quote
LinkerH Posted August 21, 2023 Author Report Posted August 21, 2023 On 8/15/2023 at 11:29 AM, Dr. McKay said: This is not officially supported and is liable to break at any time. If you need to handle a message that isn't already directly supported in SteamUser, and you don't want to fork the project and submit the changes as a pull request, then you should call _handlerManager.add as you are in the code above, but instead of passing an arrow function as the handler method, pass a regular anonymous function. Then, in the handler function, this will refer to the SteamUser instance that received the message (see how it's done in the module here). You will also need to handle protobuf encoding and decoding yourself if the messages aren't already mapped in 03-messages.js. Thank you very much Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.