nickmura aka bobby Posted August 31, 2023 Report Posted August 31, 2023 (edited) Hello, I'm trying to refactor my service in Svelte-kit, and I've been running into quite tedious errors when testing and initializing a user. Here is a quick test when a user sends a post request, which would initialize the user, run some business logic, and then log off. I've ran essentially the same code in an express environment, with the same environment variables, which worked fine. export const POST = async ({request:request}) => { //TODO const client = new SteamUser(); const community = new SteamCommunity(); const manager = new TradeOfferManager({ steam: client, community: community, language: 'en', }); const cred = { accountName: STEAM_NAME, password: STEAM_PASS, twoFactorCode: SteamTotp.generateAuthCode(STEAM_SHARED), logonID: 12345 }; client.logOn(cred); // logging on client.on('loggedOn', async () => { console.log('logged into steam'); client.setPersona(SteamUser.EPersonaState.Online) }) client.on('webSession', (sessionid, cookies) => { manager.setCookies(cookies); community.setCookies(cookies); community.startConfirmationChecker(12500, STEAM_IDENTITY); }) async function doTradeStuff() { //TODO } //await doTradeStuff() client.logOff(); // logging off client.on('disconnected', async (eresult, msg) => { console.log('logged off steam', eresult, msg) }) return json({place: 'holder'}) } Firstly, in all of the iterations I've made, I keep getting this `Error: LogonSessionReplaced 34`, which your documentation states could be mitigated / prevented by the logonID property when using the logOn method https://github.com/DoctorMcKay/node-steam-user#logondetails. However the issue still persists. Secondly, the logOff method never runs in the serverless environment, as I do not get a disconnected event. https://github.com/DoctorMcKay/node-steam-user#disconnected So, I'm looking for any guidance / hint as to where to look, where I'm going wrong, if there's better practice, what to be aware about if I'm trying to run this in a serverless environment, etc. Thanks for your libraries. Edited August 31, 2023 by nickmura aka bobby 'logOff function' to 'logOff method' Quote
Dr. McKay Posted August 31, 2023 Report Posted August 31, 2023 Using steam-user in a serverless environment is really not a good idea, unless your environment runs very infrequently. the logOff() method isn't doing anything for you because you're calling it synchronously right after logOn(). logOff() does nothing if not already logged on. You'd need to call client.logOff() inside your doTradeStuff method, at the end after everything has been done. Quote
nickmura aka bobby Posted August 31, 2023 Author Report Posted August 31, 2023 (edited) 7 minutes ago, Dr. McKay said: Using steam-user in a serverless environment is really not a good idea, unless your environment runs very infrequently. the logOff() method isn't doing anything for you because you're calling it synchronously right after logOn(). logOff() does nothing if not already logged on. You'd need to call client.logOff() inside your doTradeStuff method, at the end after everything has been done. The test successfully logs in, and logOff is not an asynchronous method I thought? Anyways, your opinion is much better than mine, and if it's not a good idea to have a serverless backend, then I don't need to log out I guess. do you think you could you elaborate a bit on why it's bad? Thx Edited August 31, 2023 by nickmura aka bobby Quote
Dr. McKay Posted August 31, 2023 Report Posted August 31, 2023 logOff() is not async, no. But you're calling it before you're actually logged on, because you're calling it synchronously along with logOn(). A couple reasons why running steam-user serverless is a bad idea: You can only log on once every 30 seconds because that's how frequently TOTP codes change Steam will start throttling your logon attempts, even if you don't have any failed logons Your request responses will take quite a long time with all the overhead of logging on each time nickmura aka bobby 1 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.