Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Very verbose example on how to connect qsocks to a server.
var qsocks = require('qsocks');
var fs = require('fs');
var request = require('request');
//Set our request defaults, ignore unauthorized cert warnings as default QS certs are self-signed.
var r = request.defaults({
rejectUnauthorized: false,
host: '',
pfx: fs.readFileSync("C:\\QlikTech\\Demo Team\\Node\\qsocks\\client.pfx")
//Authenticate whatever user you want
var b = JSON.stringify({
"UserDirectory": 'qtsel',
"UserId": 'akl',
"Attributes": []
//Get ticket for user{
uri: '',
body: b,
headers: {
'x-qlik-xrfkey': 'abcdefghijklmnop',
'content-type': 'application/json'
function(err, res, body) {
//Consume ticket, set cookie response in our upgrade header against the proxy.
var ticket = JSON.parse(body)['Ticket'];
r.get('' + ticket, function(error, response, body) {
var cookies = response.headers['set-cookie'];
//qsocks config, merges into standard https/http object headers.
//Set the session cookie correctly.
var config = {
host: '',
isSecure: true,
origin: 'http://localhost',
rejectUnauthorized: false,
headers: {
"Content-Type": "application/json",
"Cookie": cookies[0]
//Connect to qsocks/qix engine
qsocks.Connect(config).then(function(global) {
//Get our global handle
global.createApp('This is a new app', 'First Script Tab').then(function(success) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.