dhleong / playactor

play around with your playstation devices
143 stars 13 forks source link

playactor login (registration) with PS5: Unhandled 'error' event #23

Closed LordZork closed 3 years ago

LordZork commented 3 years ago

This is actually similar to what @dwffls most recently experienced/mentioned shortly before you closed https://github.com/dhleong/playactor/issues/19.

I have not encountered the removeAllListeners error that was also mentioned, only the error below... which I have experienced with both playactor 0.2.0 and playactor 0.2.1.

Notes:

USAGE/SETUP

  1. Using Homebridge on a Raspberry Pi, flashed to an SD card – i.e., no OS on the Pi, other than Homebridge, which uses Raspbian GNU/Linux Buster (10).

  2. Using node.js v14.16.1 and npm v7.9.0.

  3. Using Homebridge UI (homebridge-config-ui-x v4.41.0) via the web interface homebridge.local/ – via Google Chrome – from my Mac (macOS 10.15.7), to connect to/manage Homebridge and related plugins, and to run Homebridge Terminal installs, commands, etc. (which are all running on the Pi).

ATTEMPTS/RESULTS

  1. When I attempt playactor login in Homebridge Terminal (where playactor is operating), it returns: In a moment, we will attempt to open a browser window with the following URL: <url> Perform login there, then, when the page shows "redirect", copy the URL from your browser's address bar and paste it here. Hit ENTER to continue

  2. Based on my usage/setup (I'm guessing), the provided <url> doesn't auto-open. I have to click on the <url> link, which then opens in a new browser window/tab on my Mac (OUTSIDE of where playactor is operating).

  3. After clicking on/opening the provided <url> and logging in, I copy/paste the "redirect" URL – into Homebridge Terminal (where playactor is operating) in the homebridge.local/ browser window/tab – and then "Hit ENTER to continue".

  4. The result is the following error(s), which is what @dwffls most recently experienced/mentioned...

ERROR(S)

URL> events.js:292
      throw er; // Unhandled 'error' event
      ^

Error: spawn xdg-open ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:269:19)
    at onErrorNT (internal/child_process.js:465:16)
    at processTicksAndRejections (internal/process/task_queues.js:80:21)
Emitted 'error' event on ChildProcess instance at:
    at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
    at onErrorNT (internal/child_process.js:465:16)
    at processTicksAndRejections (internal/process/task_queues.js:80:21) {
  errno: -2,
  code: 'ENOENT',
  syscall: 'spawn xdg-open',
  path: 'xdg-open',
  spawnargs: [
    '<url>'
  ]
}

@dhleong, per your request from ps4-waker#150, I will continue any setup-specific discussions (i.e., using playactor with Homebridge) here: discussion #22.

@aclerok, would you view discussion #22 and – if possible – explain your playactor and Homebridge setup/steps, and any other related setup/steps, as well as the steps you used to resolve your login issue(s)? Thanks!

dhleong commented 3 years ago

Wow, thanks for the very detailed issue report!

Should be easy enough to handle but in the meantime a simple workaround is to do the setup on your Mac and copy the credentials file over to the device. Credentials are stored at ~/.config/playactor

dhleong commented 3 years ago

Also, to provide a little more detail: it's waiting to open the URL until you hit enter; you see the error after you paste and hit enter because that's what triggers it to try (and fail) to open the URL.

LordZork commented 3 years ago

Wow, thanks for the very detailed issue report!

Should be easy enough to handle but in the meantime a simple workaround is to do the setup on your Mac and copy the credentials file over to the device. Credentials are stored at ~/.config/playactor

@dhleong, I apologize for being such a noob here, but could you provide a bit more detail regarding the workaround?

  1. How do I do the setup on my Mac? What do I use, etc.?
  2. How do I copy the credentials file over to the device?

The device is my Raspberry Pi, which is not running an OS with a file (folder) system (that I know of)... just Homebridge (with Homebridge UI – via the web interface homebridge.local/ – and Homebridge Terminal), which is flashed to the SD card.

I am not sure how I would access or copy the credentials file over to the device. Would this all be done via Terminal?

Also, when you say this "should be easy enough to handle," does that mean you should be able to update playactor so a workaround, in this scenario, won't be necessary? I'm just curious, in case I'm unable to figure out the workaround, lol.

Thanks again for all your playactor work/effort, and for your help here!

@aclerok, I am starting to think you ran into a similar issue and had to implement a workaround as well. Would you be able to provide more detail? Thanks!

dhleong commented 3 years ago
  1. How do I do the setup on my Mac? What do I use, etc.?

Run playactor login from the terminal after installing it per the README

  1. How do I copy the credentials file over to the device?

The device is my Raspberry Pi, which is not running an OS with a file (folder) system (that I know of)... just Homebridge (with Homebridge UI https://github.com/oznu/homebridge-config-ui-x#readme – via the web interface homebridge.local/ – and Homebridge Terminal), which is flashed to the SD card.

I am not sure how I would access or copy the credentials file over to the device. Would this all be done via Terminal?

I don’t know anything about Homebridge or how that works, but I would assume there’s some flavor of linux running under the hood. The normal way to access a headless device like that would be to have a ssh server running and you could do something like:

scp -r ~/.config/playactor :~/.config/playactor

But again, I don’t know how Homebridge works. You may be able to do this through its web interface, but I have no idea.

Also, when you say this "should be easy enough to handle," does that mean you should be able to update playactor https://github.com/dhleong/playactor so a workaround, in this scenario, won't be necessary? I'm just curious, in case I'm unable to figure out the workaround, lol.

I’ll be able to update playactor to handle your scenario! Basically just need to be more careful around launching that URL and maybe make the instructions clearer.

Thanks again for all your playactor https://github.com/dhleong/playactor work/effort, and for your help here!

:)

aclerok commented 3 years ago

What I found in my install was this: you are running the playactor login from a different user than Homebridge is actually running on the raspberry pi. I had to use VNC and get logged in as the same user that my homebridge service was running as, and then issue the playactor login command there and complete the process as documented. This created the .config/playactor directory and files underneath the correct user, and it began working.

What @dhleong is mentioning above with copying your folder is essentially doing the same thing. In practice might be easier than my method, as there were multiple steps to get the homebridge user the correct permissions, etc.

LordZork commented 3 years ago

@dhleong, thanks!! I may wait for the update, though, as I'm still not sure I fully understand the workaround... and I'm not sure I want to try, especially knowing that an update/fix is imminent.

@aclerok, thanks for the info! Though, I'm not sure I understand why your setup was/is running from a different user than the Homebridge service.

How is your Homebridge setup? It sounds like you have an OS installed on your Raspberry Pi, and then you installed Homebridge within that OS? If so, does that mean you used VNC to remote into the OS installed on the Pi, and then manage Homebridge from there?

For my setup, since I don't have an OS installed on my Pi (and thus don't have Homebridge installed within an OS), I have to manage Homebridge externally (from a different computer), via the web interface homebridge.local/. As such, I'm guessing there is nothing for me to VNC into.

I'm wondering if my issue is "user" related, like yours was... or if my issue is different? Were you getting the same error as me?

aclerok commented 3 years ago

@LordZork

It sounds like you have an OS installed on your Raspberry Pi, and then you installed Homebridge within that OS? If so, does that mean you used VNC to remote into the OS installed on the Pi, and then manage Homebridge from there?

Yes, this is my scenario exactly. I'm not sure exactly how the web based console works in your setup. Essentially I consoled in to my Pi as User1 and the homebridge software was running as User2. Since I ran the playactor login as User1, User2 didn't have the credentials available to it.

LordZork commented 3 years ago

@dhleong I installed the latest playactor update (0.2.2), but I'm still running into the same issue. The only difference is that now it only shows the URL (that it wants to auto-open) after I hit enter.

I've tried hitting enter without pasting the "redirect," and I've tried pasting the "redirect" and then hitting enter. Both ways result in the same error as before (shown below).

Why can't I just paste the "redirect" and hit enter? How is this supposed to work? It's unclear as I feel like I am following the instructions but can't get past this registration process and resulting error.

The only thing I can think of is that, due to my setup, the auto-open URL thing is the hangup. Is it possible to remove the need to auto-open the URL and just let people click on the link, and then paste the "redirect" and hit enter?

I use ps4-waker (with the same Homebridge setup) without any issues, so it must be possible.

Attempt/errors

pi@homebridge:/var/lib/homebridge $ playactor login

In a moment, we will attempt to open a browser window for you to login to your PSN account.
When the page shows "redirect", copy the URL from your browser's address bar and paste it here.
Hit ENTER to continue
URL> events.js:292
      throw er; // Unhandled 'error' event
      ^

Error: spawn xdg-open ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:269:19)
    at onErrorNT (internal/child_process.js:465:16)
    at processTicksAndRejections (internal/process/task_queues.js:80:21)
Emitted 'error' event on ChildProcess instance at:
    at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
    at onErrorNT (internal/child_process.js:465:16)
    at processTicksAndRejections (internal/process/task_queues.js:80:21) {
  errno: -2,
  code: 'ENOENT',
  syscall: 'spawn xdg-open',
  path: 'xdg-open',
  spawnargs: [
    '<url>'
  ]
}
dhleong commented 3 years ago

The auto-open is definitely the hang up. The library apparently does not work the way I thought it did. Basically the error isn’t getting caught by the library the way I expected it to, which is crashing the rest of the process. Since I can’t repro, I just guessed based on an (incorrect) assumption. Should still be easy enough to fix; I’ll take another look either later today or tomorrow morning.

On Apr 14, 2021 at 1:23:03 PM, LordZork @.***> wrote:

@dhleong https://github.com/dhleong I installed the latest playactor https://github.com/dhleong/playactor update (0.2.2 https://github.com/dhleong/playactor/releases/tag/0.2.2), but I'm still running into the same issue. The only difference is that now it only shows the URL (that it wants to auto-open) after I hit enter.

I've tried hitting enter without pasting the "redirect," and I've tried pasting the "redirect" and then hitting enter. Both ways result in the same error as before (shown below).

Why can't I just paste the "redirect" and hit enter? How is this supposed to work? It's unclear as I feel like I am following the instructions but can't get past this registration process and resulting error.

The only thing I can think of is that, due to my setup, the auto-open URL thing is the hangup. Is it possible to remove the need to auto-open the URL and just let people click on the link, and then paste the "redirect" and hit enter?

I use ps4-waker https://github.com/dhleong/ps4-waker (with the same Homebridge setup) without any issues, so it must be possible. Attempt/errors

@.***:/var/lib/homebridge $ playactor login

In a moment, we will attempt to open a browser window for you to login to your PSN account. When the page shows "redirect", copy the URL from your browser's address bar and paste it here. Hit ENTER to continue

URL> events.js:292 throw er; // Unhandled 'error' event ^

Error: spawn xdg-open ENOENT at Process.ChildProcess._handle.onexit (internal/child_process.js:269:19) at onErrorNT (internal/child_process.js:465:16) at processTicksAndRejections (internal/process/task_queues.js:80:21) Emitted 'error' event on ChildProcess instance at: at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12) at onErrorNT (internal/child_process.js:465:16) at processTicksAndRejections (internal/process/task_queues.js:80:21) { errno: -2, code: 'ENOENT', syscall: 'spawn xdg-open', path: 'xdg-open', spawnargs: [ '' ] }

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/dhleong/playactor/issues/23#issuecomment-819687237, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAGHIFQKVAE2YYZVMYWEATDTIXFPPANCNFSM422EUH2Q .

LordZork commented 3 years ago

@dhleong sounds good, thanks again for all your work on this!

dhleong commented 3 years ago

Check out v0.2.3; hopefully this will catch that error more gracefully!

LordZork commented 3 years ago

@dhleong, perfect—that did the trick! Thanks!!!

tommyMX commented 2 years ago

Hi,

i have the playactor on a Synology NAS running in a docker. How can I fix this with the open browser problem?

Thank You