# \`samsung\` node remote control flow working - then it doesn't

**URL:** <https://discourse.nodered.org/t/samsung-node-remote-control-flow-working-then-it-doesnt/75336>\
**Category:** General\
**Created:** [17 February 2023 08:52 UTC](https://discourse.nodered.org/t/samsung-node-remote-control-flow-working-then-it-doesnt/75336 "2023-02-17T08:52:43Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [17 February 2023 08:52 UTC](https://discourse.nodered.org/t/samsung-node-remote-control-flow-working-then-it-doesnt/75336/1 "2023-02-17T08:52:44Z")

</div>

Sorry folks, little information to give, but if I don't ask the problem won't go away.

I have a flow that uses the `samsung` node to control my Samsung TV.  
At given times it controls the channel.

Alas recently one of them stopped working.

# Base line:

I have a few of these _events_ and the channels change at their given time.  
Recently one of them have stopped working.  
I have 2 others that are also regular and today they worked.

# Observations:

I have a similar thing which is more a `remote control` duplication on ANOTHER machine.  
The even happens, nothing happens on the TV.  
If I use the other machine to adjust the volume it works.  
Then I go back and test the event again and it works.

There are no **ERRORS** just a message (which sorry I've since deleted).

--

Ok, I will have to try and remember to capture the message that is given next time.  
Alas it may be difficult as I have an error handling routine but it doesn't capture anything.  
I just see these messages in the `debug` list (right side of screen).

It just seems strange that it works _earlier on_ that day, but at this specific time / event: it doesn't work.

Yet it used to work daily without any problem.

# Update:

Ok after a bit of testing I got the problematic message back.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/1/3118bc4a1c3e726cd1fab0038c249e8b77d2a0c2.png)

`RangeError: Invalid WebSocket frame: invalid status code 1005`

But as said: It works/ed twice today already so the _third_ time it throws this message.  
But if I manually do it (now) for testing: It works.

---

<div class="post-metadata">

**Author:** ![Bobo](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bobo/32/8401_2.png) [@Bobo](https://discourse.nodered.org/u/Bobo)\
**Post date:** [18 February 2023 07:48 UTC](https://discourse.nodered.org/t/samsung-node-remote-control-flow-working-then-it-doesnt/75336/2 "2023-02-18T07:48:38Z")

</div>

Is this related?

> <https://github.com/Toxblh/node-red-contrib-samsung-tv-control/issues/23>
>
> After using the node for a short while it stops working and gives errors in debu…g console:
> !\[image\](https://user-images.githubusercontent.com/3331076/87338193-6d973080-c54d-11ea-8cf2-dde494841138.png)
> Restarting node-red fixes bring it back to work.
> 
> I also noticed that there is no exception handling of websocket things in this node and in some cases this node just makes node-red crash and makes systemd start it again.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [18 February 2023 21:03 UTC](https://discourse.nodered.org/t/samsung-node-remote-control-flow-working-then-it-doesnt/75336/3 "2023-02-18T21:03:12Z")

</div>

Thanks @Bobo.  
Of course after my posting the question the problem has kind of started behaving itself.

For the sake of not wasting people's time, I'll accept that and close this thread.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [1 March 2023 05:12 UTC](https://discourse.nodered.org/t/samsung-node-remote-control-flow-working-then-it-doesnt/75336/4 "2023-03-01T05:12:01Z")

</div>

Just a quick question as a kind of follow up:

How can I _detect_ those messages happening?  
The `catch` node doesn't seem to do it as it isn't an error.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [4 March 2023 08:39 UTC](https://discourse.nodered.org/t/samsung-node-remote-control-flow-working-then-it-doesnt/75336/5 "2023-03-04T08:39:34Z")

</div>

Ok, I have a (sort of) active thread on this.

This problem is an intermittent problem with a node. (Samsung)

I have a `catch` node on this flow but it doesn't catch these messages.

Screen shot:

 ![Screenshot from 2023-03-04 19-32-01](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/e/be0292c8a75df0b2bde280d1fd591e5ccb95e457.png)

The error catcher for that flow.  
Ok, `subflow` there. But all messages are queued for edit screen looking.  
(Second screen shot)

 ![Screenshot from 2023-03-04 19-34-16](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/5/358585b53e573834afa105786b2b2ff3eb6e18db.png)

So as you can see it isn't being _seen_ as an error.

Again: (as I can't really resolve an answer from the other thread) how can I _catch_ those messages and then make things happen.  
Ok, the latter part is my problem and I am sure I can deal with that.  
But _catching_ that message....

## HOW?

Thanks.  
(I'm doing it here now as it just happened and is hard to make happen to test it)

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [4 March 2023 09:10 UTC](https://discourse.nodered.org/t/samsung-node-remote-control-flow-working-then-it-doesnt/75336/6 "2023-03-04T09:10:59Z")

</div>

The ideal solution is to submit an issue on the node to get it to trigger a catch-able error.  
If the node is not supported then maybe you could fork it and fix it yourself.

In the meantime they should appear in the node red log, so potentially you could tail that. On a pi, for example, they should be in /var/log/syslog.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [4 March 2023 09:16 UTC](https://discourse.nodered.org/t/samsung-node-remote-control-flow-working-then-it-doesnt/75336/7 "2023-03-04T09:16:11Z")

</div>

Ok.

Thanks.

I fear that the node is no longer supported. ☹

Your next suggestions are above my skills.  
So there is no way to _catch_ the message with an existing node?

Ideally I only need to catch one of the messages. Not from all nodes.  
As basically the `<enter>` is pressed at the end of a each _sequence_ and is in them all.

---

<div class="post-metadata">

**Author:** ![Paul-Reed](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paul-reed/32/66906_2.png) [@Paul-Reed](https://discourse.nodered.org/u/Paul-Reed)\
**Post date:** [4 March 2023 09:26 UTC](https://discourse.nodered.org/t/samsung-node-remote-control-flow-working-then-it-doesnt/75336/8 "2023-03-04T09:26:29Z")

</div>

You don't say which node you are actually using... and checking the flows, I can see 7 'samsung' contrib nodes listed.  
Have you tried any of the others?

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [4 March 2023 09:28 UTC](https://discourse.nodered.org/t/samsung-node-remote-control-flow-working-then-it-doesnt/75336/9 "2023-03-04T09:28:20Z")

</div>

The one I am using is `node-red-contrib-samsung-tv-control`  
You set the _attribute_ of the node to tell it which button to emulate when it gets a signal.

So all the 7 you see are the same just configured to emulate 7 buttons.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [4 March 2023 09:41 UTC](https://discourse.nodered.org/t/samsung-node-remote-control-flow-working-then-it-doesnt/75336/10 "2023-03-04T09:41:22Z")

</div>

> [@Trying\_to\_learn](#):
>
> Ideally I only need to catch one of the messages. Not from all nodes.

Look in syslog when it happens. All the information you need is there to catch the error in a Tail node.

---

<div class="post-metadata">

**Author:** ![Sean-McG](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sean-mcg/32/54677_2.png) [@Sean-McG](https://discourse.nodered.org/u/Sean-McG)\
**Post date:** [4 March 2023 11:38 UTC](https://discourse.nodered.org/t/samsung-node-remote-control-flow-working-then-it-doesnt/75336/11 "2023-03-04T11:38:13Z")

</div>

You problem seems to be covered by the issue that @Bobo linked to.

There is a possible fix in that thread, why don't you try that ?

Open .node-red/node\_modules/samsung-tv-control/lib/samsung.js with a text editor eg **nano** etc.

Then find the section below and add this line as shown -  
**setTimeout(() =\> ws.close(), 250);**

```auto
_send(command, done, eventHandle) {
        const ws = new WebSocket(this.WS_URL, { rejectUnauthorized: false });
        this.LOGGER.log('command', command, '_send');
        this.LOGGER.log('wsUrl', this.WS_URL, '_send');
        ws.on('open', () => {
            if (this.PORT === 8001) {
                setTimeout(() => ws.send(JSON.stringify(command)), 1000);
            }
            else {
                ws.send(JSON.stringify(command));
				setTimeout(() => ws.close(), 250); 
            }
        });

```

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [5 March 2023 05:21 UTC](https://discourse.nodered.org/t/samsung-node-remote-control-flow-working-then-it-doesnt/75336/12 "2023-03-05T05:21:04Z")

</div>

Sometimes I can't see _the wood for the trees_.

Applied and shall see what happens now.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [7 March 2023 09:27 UTC](https://discourse.nodered.org/t/samsung-node-remote-control-flow-working-then-it-doesnt/75336/13 "2023-03-07T09:27:26Z")

</div>

Will I have to restart Node-Red after I modify the code?  
Or is it called when needed?

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [7 March 2023 10:04 UTC](https://discourse.nodered.org/t/samsung-node-remote-control-flow-working-then-it-doesnt/75336/14 "2023-03-07T10:04:55Z")

</div>

All node code is loaded at node-red startup, so you will have to start node-red. I don't understand why you bothered to even ask, would it not have been easier just to restart?

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [7 March 2023 10:09 UTC](https://discourse.nodered.org/t/samsung-node-remote-control-flow-working-then-it-doesnt/75336/15 "2023-03-07T10:09:43Z")

</div>

I just wanted to check.

Don't underestimate my stupidity. 😉
