jonathonmcmurray / ws.q

Simple library for websockets in kdb+/q
MIT License
32 stars 12 forks source link

OS reports: Protocol not available when running example #6

Closed ksk438 closed 5 years ago

ksk438 commented 5 years ago

q).bfx.upd:{.bfx.x,:enlist x} q).bfx.h:.ws.open["wss://api.bitfinex.com/ws/2";.bfx.upd] 'conn. OS reports: Protocol not available [2] /home/scope/scratch/repos/ws/ws.q:16: .ws.open0: d:(enlist"Origin")!enlist h; //use Origin header s:first r:hs d:.req.buildquery[GET;pr;x;h;d;()]; //build query & send ^ if[v;-1"-- REQUEST --\n",string[hs]," ",d]; //if verbose, log request q.ws))

Running 64bit kdb on ubuntu virtual machine... any help would be appreciated

jonathonmcmurray commented 5 years ago

So for this you'll need to set up HTTPS client certificates

You can see here for details:

https://code.kx.com/q/cookbook/ssl/#tls-client-mode

If you're using Anaconda/miniconda, you can also install my qhttps package like so:

$ conda install -c jmcmurray qhttps

which should automatically configure it correctly within your conda environment. You can check your SSL config within q using

q)-26!()
SSLEAY_VERSION   | OpenSSL 1.0.2g  1 Mar 2016
SSL_CERT_FILE    | /usr/lib/ssl/server-crt.pem
SSL_CA_CERT_FILE | /opt/kdb/certs/cabundle.pem
SSL_CA_CERT_PATH | /usr/lib/ssl
SSL_KEY_FILE     | /usr/lib/ssl/server-key.pem
SSL_CIPHER_LIST  | ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RS..
SSL_VERIFY_CLIENT| NO
SSL_VERIFY_SERVER| YES

Important key here is SSL_CA_CERT_FILE; if you get an error running -26!() it could be an incompatible version of OpenSSL, you need version 1.0., kdb+ isn't compatible with version 1.1. [I'll update my qhttps package later to make sure this is specified so that installing that package will also make sure correct version of OpenSSL is installed]

ksk438 commented 5 years ago

Got it working by setting LD_LIBRARY_PATH to the directory with libssl.so

Thanks!

jonathonmcmurray commented 5 years ago

Glad you got it working, closing the issue