Function node export object from start section

I use a function node to connect to socket.io, thus creating a socket object in the Start tab.
I need access to that socket object in the Stop section, to close the connection again.
Alternatively, node.on('close', ...) would work, but node#on does not seem to be available in the Setup tab.

So here is the question:
How do I access objects created in the start code from the stop code?

By setting a reference in node context.

on start

context.set('mySocket', mySocket)

on stop

const soc = context.get('mySocket')
soc.whatever()

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.