Transformation throws exception

Dear all,
Again, :frowning:

2018-10-06 02:37:03.040 [ERROR] [ab.binding.exec.internal.ExecBinding] - transformation throws exception [transformation=JS(parseEpson.js), response=]
org.openhab.core.transform.TransformationException: An error occurred while loading script.

I try this :

(function(i) {
    if (i === 'video: muted\naudio: muted')
    	return "ON";
    else if (i === 'on')
        return "ON";
    else if (i === 'off')
        return "OFF";
})(input)

There are no errors in that script that I can see.
Try:

(function(i) {
    if (i === 'video: muted\naudio: muted') {
    	return "ON";
    } else if (i === 'on') {
        return "ON";
    } else if (i === 'off') {
        return "OFF";
    }
})(input)

Same way, always the same error.
I have delete my item :

{exec="<[ON:/usr/local/bin/pjlink -p projector:4352 power:5000:JS(parseEpson.js)] >,,,,,,,,,,,}

What version of OpenHAB are you running?
Try removing the javascript transform
Stop OH
Start OH
Install the transform again

I have this bug with OH Build 2.2 and 2.2.0 Javascript Transformation and after with
2.3 and 2.3.0 Javascript Transformation. I can try but i’m not sure that it corrects the problem.
Maybe I will try to downgrade java runtime.

What version of Java are you running?
java -version

Actually 1.8.0_181
I’m not sure but I think when I did some tests before to choose OH I had _131 and no problem but maybe I didn’t do enough.

It’s not java. Your version is correct

Can you post you items and rules related to this error again, please?
I’d like to get to the bottom of it, because it should work.

items

// Projectors

Switch videoprojector1 "CCC-PROJ-01 ON/OFF"	(All, Projector) {exec="<[/usr/local/bin/pjlink -p CCC-PROJ-01:4352 power:5000:JS(parseEpson.js)] >[ON:/usr/local/bin/pjlink -p CCC-PROJ-01:4352 power on] >[OFF:/usr/local/bin/pjlink -p CCC-PROJ-01:4352 power off]"}
Switch videoprojector1mute   "CCC-PROJ-01 Mute"		(ProjectorMute)  {exec=">[ON:/usr/local/bin/pjlink -p CCC-PROJ-01:4352 mute all] >[OFF:/usr/local/bin/pjlink -p CCC-PROJ-01:4352 unmute all]"}
Switch videoprojector1pwr "CCC-PROJ-01 PWR"	(All, ProjectorPwr) {knx="2/0/1+<2/0/101"}

Switch videoprojector2 "CCC-PROJ-02 ON/OFF"	(All, Projector) {exec="<[/usr/local/bin/pjlink -p CCC-PROJ-02:4352 power:5000:JS(parseEpson.js)] >[ON:/usr/local/bin/pjlink -p CCC-PROJ-02:4352 power on] >[OFF:/usr/local/bin/pjlink -p CCC-PROJ-02:4352 power off]"}
Switch videoprojector2mute   "CCC-PROJ-02 Mute"		(ProjectorMute)  {exec=">[ON:/usr/local/bin/pjlink -p CCC-PROJ-02:4352 mute all] >[OFF:/usr/local/bin/pjlink -p CCC-PROJ-02:4352 unmute all]"}
Switch videoprojector2pwr "CCC-PROJ-02 PWR"	(All, ProjectorPwr) {knx="2/0/2+<2/0/102"}

parseEpson.js

(function(i) {
    if (i === 'on')
    	return "ON";
    else if (i === 'off')
        return "OFF";
})(input)

there is nothing in rules for this

all this “copy past” is the last version of my code, this code generate always the same error since the start
sometimes this error happen in 4 days, sometimes in 10 days.

2018-10-06 02:37:03.040 [ERROR] [ab.binding.exec.internal.ExecBinding] - transformation throws exception [transformation=JS(parseEpson.js), response=]
org.openhab.core.transform.TransformationException: An error occurred while loading script.

this morning I have deleted

<[/usr/local/bin/pjlink -p CCC-PROJ-01:4352 power:5000:JS(parseEpson.js)]

maybe I can try the binding Epson and stop to try this way to have ON OFF information

thanks for your help

Since it happens intermittently, it could be that you have a time out and that would generate an error in the transformation.
Have you tried increasing the timeout to 10 seconds or maybe more?

Have you tried increasing the timeout to 10 seconds or maybe more?

How can I do this ?

Change the 5000 to 10000

Switch videoprojector1 "CCC-PROJ-01 ON/OFF"	(All, Projector) {exec="<[/usr/local/bin/pjlink -p CCC-PROJ-01:4352 power:10000:JS(parseEpson.js)] >[ON:/usr/local/bin/pjlink -p CCC-PROJ-01:4352 power on] >[OFF:/usr/local/bin/pjlink -p CCC-PROJ-01:4352 power off]"}

Ok that’s what I thought. I do that. I’ll let you know in a few days, thank you Vincent

Or, you could find out, what’s returned on a time out and deal with it in your transform.

I haven’t been following this thread that closely so I apologize if this has already been mentioned.

What if i !== 'on' and i !== 'off'? The transform doesn’t return anything. I can easily see that causing an error. I’d at least add an else and return something meaningful for the case when i doesn’t match either if clause.

Hello rlkoshak
No because at the beginning of the problem I had an ELSE for this situation.
For the lasted test I have removed it but I think It’s better with a ELSE.

Dear all,
For the moment I have removed the line with parseEpson.js
But this morning new problem without the line :

2018-10-12 22:47:43.139 [WARN ] [lipse.jetty.server.AbstractConnector] - 
java.io.IOException: Too many open files

Maybe there is a link between parseEpson.js error and this error

$ ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
file size               (blocks, -f) unlimited
max locked memory       (kbytes, -l) unlimited
max memory size         (kbytes, -m) unlimited
open files                      (-n) 256
pipe size            (512 bytes, -p) 1
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 1418
virtual memory          (kbytes, -v) unlimited

I’m on Mac Sierra OS.
I think if I increase the number of max file I probably stop the error of parseEpson.js
I will do it Monday !
I will let you know if it corrects the problem.

It seems to work very well.
It was a problem with ulimit -a on mac OS

Thanks for all

Dear all,
OMG, the problem is always present.

It seems to be a bug only with BasicUI