samsung-tv-control
samsung-tv-control copied to clipboard
"event": "ms.channel.unauthorized" when sending a command
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"
}
you should use port 8002
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
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
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.
@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,
};