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

getSessionTicketWithSteamId Failing with Generic Error: GenericFailure channel closed. #165

Open
Pieeer1 opened this issue Sep 13, 2024 · 4 comments

Comments

@Pieeer1
Copy link

Pieeer1 commented Sep 13, 2024

I have the following:

    const steamworks = require('steamworks.js')

    const steamClient = steamworks.init(MY_APP_ID);

    const steamId = steamClient.localplayer.getSteamId().steamId64;
    
    //WORKS
    ipcMain.handle('steam-id', () => {
      return steamId;
    })
    //WORKS
    ipcMain.handle('steam-name', () => {
      return steamClient.localplayer.getName();
    });

//DOES NOT WORK
    ipcMain.handle('steam-session-ticket', async () => {

      try {
        const ticket = await steamClient.auth.getSessionTicketWithSteamId(steamId)
        
        console.log(`Steam Ticket: ${ticket}`)
        console.log(`Steam Ticket: ${ticket.getBytes()}`)

      }catch (e) {
        console.error(`Steam Not Loaded: ${e}`)
      }

      return await steamClient.auth.getSessionTicketWithSteamId(steamId);
    })

The steam client is instantiated and ready to go, but the session ticket is failing with a GenericFailure

@Pieeer1
Copy link
Author

Pieeer1 commented Sep 13, 2024

This then functions later when the client is actually functional. Seems to be a timing issue.

that being said, is there a way to trigger an event when the client is actually ready? or is there a flag I am missing for this?

@ceifa
Copy link
Owner

ceifa commented Sep 14, 2024

what do you mean by the client being ready?

@Pieeer1
Copy link
Author

Pieeer1 commented Sep 14, 2024

A ticket is successfully able to be generated would be my idea. Maybe some additional callback?

@Pieeer1
Copy link
Author

Pieeer1 commented Sep 17, 2024

Couldn't get this working as a callback with any current functionality. Workaround is to retry with a delay:

ipcMain.handle('steam-session-ticket', async () => {

      const getRetryableSteamAuthTicket = async (delay: number, times: number) => {
        try{
          return (await steamClient.auth.getSessionTicketWithSteamId(steamId)).getBytes().toString('hex');
        } catch(e) {
          if(times > 7){
            dialog.showErrorBox('Steam Error', `Failed to get steam session ticket: ${e}`);
            app.quit();
            throw e;
          } else {
            await new Promise((resolve) => setTimeout(resolve, delay));
            return getRetryableSteamAuthTicket(delay * 2, times + 1);
          }
        }
      }

      return getRetryableSteamAuthTicket(1000, 0);
    })

which is pretty gross but it is working on all tested machines.

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

No branches or pull requests

2 participants