Websocket connections inside a function node

You cannot use standard Websockets inside Node-Red because it is base on NodeJS. You need to use an external library like ws

Evenmore, inside a function Node it is not the best for that. Use the built-in components.