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

Old issue: Maximum retries and/or timeout on connect not working? #133

Open
Jibun-no-Kage opened this issue Aug 7, 2024 · 0 comments
Open

Comments

@Jibun-no-Kage
Copy link

Per the code and my understanding(?) The powerOnAndConnect() function should, if passed to it, adjust maximum retries and timeout per retry right? Well I set retries to 90, and timeout to 1 second, i.e. 1000, and get connection refused? TV does power up, (not WOL in state) because it is only off for a few seconds. So do I understand the code wrong? As I recall this was an old issue previously reported, so is it just not fixed yet, or something not working right now?

Code example below... should way for up to 90 seconds for TV to be FULLY online... meaning more than just a ping, but all functions working, say getCurrentApp returns valid results for example, per my understanding. But I get connection refused almost immediately, and I know the TV powers up but is not fully responding.

Test Code...

import { Inputs, LGTV } from 'lgtv-ip-control';

const lgtv = new LGTV('192.168.1.24', '7C:64:6C:93:6F:06', '7O6BOY7U');

lgtv
  .powerOnAndConnect({maxTries:90,retryTImeout:1000})
  .then(async () => {
    await new Promise((resolve) => setTimeout(resolve, 5000));
    var app=await lgtv.getCurrentApp()
    console.log("App: "+app);
    console.log('Select HDMI1...');
    await lgtv.setInput(Inputs.hdmi1);
    await new Promise((resolve) => setTimeout(resolve, 2000));
    console.log('Select HDMI2...');
    await lgtv.setInput(Inputs.hdmi2);
    console.log('Power Off...');
    await lgtv.powerOff()
  })
  .catch(console.error)
  .finally(() => lgtv.disconnect());

When TV is powered on, or has only been offline for less than about 2 minutes, everything works as expected. However, if TV has been offline, for more than about 2 minutes... it has dropped off the network and WOL is required.

But there are 2 issues....

  1. No matter how I pass the 90 retries, and the 1000 timeout, it is ignored apparently. I have tried as above, also as just raw numbers, nothing seems to be accepted. Yet I recall this was the expected behavior from past discussion.

  2. From the time WOL happens, and TV powers up, the above code continues on, attempt to return getCurrentApp() but because the TV is not 'fully' on the wired so to speak, error is generated. when getCurrentApp() called. It is pingable, but not functional. Literally the lights-are-on-but-no-one-is-home type of issue.

Here is where the retries and timeout are ignored... Does not seem to await even 10 seconds which seems to be hard coded default? TV has been offline, powered off for at least 3 minutes. Note the 10 retries, but should be 90 per the code example, right?

# node lgtv-ip-control.mjs
MaxRetriesError: maximum retries of 10 reached
    at Socket.connect (file:///root/node_modules/lgtv-ip-control/dist/classes/TinySocket.js:82:37)
    at Socket.emit (node:events:517:28)
    at Socket._onTimeout (node:net:598:8)
    at listOnTimeout (node:internal/timers:569:17)
    at process.processTimers (node:internal/timers:512:7) {
  cause: undefined
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

1 participant