# WebSocket Client Connection Library This library provides the ability to create client WebSocket connections. ## `.wsc.connect` Attempts to create a WebSocket client connection to the specified URL. Prior to attempting a connection, the function will: 1. Ensure that the `.z.ws` handler function is set 1. The URL has a valid WebSocket scheme (either `ws://` or `wss://`) 1. If a TLS-encrypted WebSocket is requested, ensure TLS is available on the current process ### Example ```q / Define a kdb process as an echo WebSocket target / $QHOME/l64/q -p 12345 / .z.ws:{ neg[.z.w] x } q) .wsc.connect "ws://localhost:12345" 2020.05.22 15:04:59.719 INFO pid-669 jas 0 Attempting to connect to ws://localhost:12345 via WebSocket 2020.05.22 15:04:59.723 INFO pid-669 jas 0 Connected to ws://localhost:12345 via WebSocket [ Handle: 4 ] 4i q) neg[4] .j.j enlist[`time]!enlist .z.p q)"{\"time\":\"2020-05-22T15:05:11.220108000\"}" ``` ## Options ### `.ws.cfg.logToIpc` If this option is set to true, all new connections established via `.wsc.connect` will be added to the `.ipc.outbound` connection tracking table, which is part of the `ipc` library. ## Configuring TLS kdb+ only searches for `libssl.so` in the library path, therefore you may need to create a symlink from the OpenSSL 1.0.x library present in your OS to `libssl.so`. For example on Ubuntu (as `root`): ``` # cd /usr/lib/x86_64-linux-gnu/ # ls -l libssl* -rw-r--r-- 1 root root 426232 Feb 26 2019 libssl.so.1.0.0 -rw-r--r-- 1 root root 577312 Nov 12 2019 libssl.so.1.1 # ln -s libssl.so.1.0.0 libssl.so # ls -l libssl* lrwxrwxrwx 1 root root 15 May 22 11:42 libssl.so -> libssl.so.1.0.0 -rw-r--r-- 1 root root 426232 Feb 26 2019 libssl.so.1.0.0 -rw-r--r-- 1 root root 577312 Nov 12 2019 libssl.so.1.1 ``` You may also need to disable server certificate validation, again depending on your OS (although this is not recommended in Production). To disable (for kdb+ processes only): ``` export KX_SSL_VERIFY_SERVER=NO ```