Skip to content


Startup a q server on localhost 8081.

\l kurl.q
server:hsym `$":localhost:",port
system "q -p ",port
server (set;`.z.pp; { system "sleep 45";})
server (set;`.z.ts; {[start;x] if[x > start + 00:00:45; exit 0]; }[.z.p;])
server (system;"t 1000")

Make a sync and async request that time out.

request_headers:enlist["Content-Type"]!enlist "application/json"
body:.j.j `hello`world!1 2
opts: `timeout`headers`body!(5000;request_headers;body)
\ts resp:.kurl.sync ("http://localhost:8081";`POST;opts)

// List the number of ongoing transfers
show "Number of ongoing transfers after sync timeout: ",
  string count .kurl.i.ongoingRequests[]

.kurl.async (
  opts,enlist[`callback]!enlist {
    if [-1 = first x; show "async call got error: ",last x];
    } )

show enlist ("Pending async calls"; .kurl.i.ongoingRequests[])