samsung-tv-control icon indicating copy to clipboard operation
samsung-tv-control copied to clipboard

"event": "ms.channel.unauthorized" when sending a command

Open hurrikam opened this issue 4 years ago • 5 comments

I'm trying to send commands to a Samsung Tizen 2018 (QE55Q8FNA) using the sample code:

const config = {
  debug: true, // Default: false
  ip: '10.189.148.65',
  mac: 'C048E64BADE5',
  name: '[TV] Samsung Q8 Series (55)', // Default: NodeJS
  port: 8001, // Default: 8002
  saveToken: true
}

const control = new Samsung(config)

await control.turnOn()
await control.isAvaliable()

let token = await control.getTokenPromise()

I can see TV information coming back, but the getTokenPromise fails with

FUNCTION: ws.on message
LOG data: 
{
  "event": "ms.channel.unauthorized"
}

hurrikam avatar Mar 17 '20 16:03 hurrikam

you should use port 8002

Toxblh avatar Mar 17 '20 16:03 Toxblh

I now get a different error:

LOG data: 
{
  "event": "ms.channel.timeOut"
}

and I can still see port 8001 being referenced in the underlying calls:

uri":"http://10.189.148.65:8001/api/v2

hurrikam avatar Mar 17 '20 16:03 hurrikam

To add more context, I've done some debugging. The call to get a token fails on sendKeys:

getToken(done) {
        this.LOGGER.log('getToken', '');
        if (this.SAVE_TOKEN && this.TOKEN !== 'null' && this.TOKEN !== '') {
            done(this.TOKEN);
            return;
        }
        this.sendKey(keys_1.KEYS.KEY_HOME, (err, res) => {
            if (err) {
                this.LOGGER.error('after sendKey', err, 'getToken');

err is: { RangeError: Invalid WebSocket frame: invalid status code 1005

hurrikam avatar Mar 18 '20 10:03 hurrikam

Changing to port 8002 fixes it for me. I also had to turn on debug mode to check which token is being generated. After I configured that token everything worked fine for me.

stijnbernards avatar May 13 '20 14:05 stijnbernards

@hurrikam I did change port to 8001 and made it work.

const config = {
  debug: true, // Default: false
  ip: "192.168.3.12",
  mac: "0123456789ABC",
  nameApp: "Yolo",
  port: 8001,
  saveToken: true,
};

aromeronavia avatar Feb 04 '22 01:02 aromeronavia