How to add username and password of kdb to web socket url?

Hi All,

In javascript,  I need to pass the url to kdb for establishing the connection.

function connect_kdb(){

   if (“WebSocket” in window)

   {

      ws = new WebSocket(“ws://127.0.0.1:6000”);

      ws.binaryType = ‘arraybuffer’;

      ws.onopen=onopen; 

      ws.onclose=onclose;

      ws.onmessage=onmessage;

      ws.onerror=onerror;

   }

   else

      alert(“WebSockets not supported on your browser.”);

   }

}

how to add username and password of kdb to web socket url?

The following format does NOT work.

ws = new WebSocket(ws://127.0.0.1:6000:username:password);

—

Roy Liu

It’s just HTTP basic auth: https://en.wikipedia.org/wiki/Basic_access_authentication#URL_encoding

so try 

ws://username:password@127.0.0.1:6000

http://stackoverflow.com/questions/6714966/basic-authentication-for-websockets

it mentions the format ‘ws://user:pass@127.0.0.1/’)

but it also mentions that Chrome doesn’t help you

I think they claimed to have fixed that in the meantime
https://bugs.chromium.org/p/chromium/issues/detail?id=123862

It works: ws://username:password@127.0.0.1:6000 

Furthermore, the issue has fixed in Google Chrome.

It doesn’t work for me. 

When I try to open a websocket with ws://username:password@127.0.0.1:6000 as URL, and define .z.pw as



.z.pw:{[u;p] show u; show p; 1b}

it does open the connection but print

q)“”`

I tried with the latest q version (KDB+ 3.3 2016.02.22) and both Chrome and Firefox.

Le vendredi 26 février 2016 02:09:07 UTC+1, Roy a écrit :

It works: ws://username:password@127.0.0.1:6000 

Furthermore, the issue has fixed in Google Chrome.