Sending triggers to RCS Port in LSL Recorder

Hi there,
I use LSL (lab streaming layer) to record EEG data. I would like to use psychophysiol (which we use to run the experiment) to start and stop the recording of LSL.

I can use the following python code which works fine if I run it through the terminal.

import socket
s = socket.create_connection((“localhost”, 22345))

However, if I add this code to the psychophysiol procedure, the trigger doesn’t get send to LSL.
I tried to write this code directly in javascript but didn’t really manage…

Any suggestions of what I could try? Or is there anyone who knows how to write these lines in javascript? I could imagine that this may solve the problem.

any thoughts on this? I assume it’s just a small thing I’m missing somehow…

Wuhay, found a solution that works.
I’M still not exactly sure why it didn’t work before, but I set up the code according to this simple example here and it works fine now: