Closed davidgutierrez closed 4 years ago
I'm having a similar issue but surely not the same. I don't want to hijack your issue, just sharing.
I'm getting an "Error: Socket closed. (onMaxParallelSessionsExceeded)" but I'm consistently closing it for every single session.
session.on('opened', () => { global.semaphore++; console.log('opened: ${this.semaphore}'); });
session.on('closed', () => { global.semaphore--; console.log('closed: ${this.semaphore}'); });
this never exceeds 1.
Node.js + Qlik Sense April 2020 + Windows .
@davidgutierrez When do you get "socket hang up". I tried against a Qlik Sense Enterprise and can't reproduce this behaviour
Did a small change to make the whole script async
const enigma = require('enigma.js');
const WebSocket = require('ws');
const schema = require('enigma.js/schemas/12.20.0.json');
const path = require('path');
const fs = require('fs');
// process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
var args = process.argv.slice(2)
var urlws = args[0];
var nombreDoc = args[1];
var userDir = args[2];
var userId = args[3];
var certPath = args[4];
var session = enigma.create({
schema,
url: `${urlws}`,
createSocket: url => new WebSocket(url, {
ca: fs.readFileSync(path.resolve(certPath, 'root.pem')),
cert: fs.readFileSync(path.resolve(certPath, 'client.pem')),
key: fs.readFileSync(path.resolve(certPath, 'client_key.pem')),
headers: {
'X-Qlik-User': `UserDirectory=${encodeURIComponent(userDir)}; UserId=${encodeURIComponent(userId)}`,
},
}),
});
(async () => {
const global = await session.open();
const docList = await global.getDocList();
docId = docList.filter(obj => obj.qTitle == nombreDoc)[0].qDocId;
console.log(`\nStarting to RELOAD the app '${nombreDoc}' with 'docId'=${docId}`);
const app = await global.openDoc(docId);
console.log(`\t- Opening the app`);
await app.doReload();
console.log(`\t- Reloading the app`);
await app.doSave();
console.log(`\t- Saving the app`);
const appInfo = await app.getAppProperties();
console.log(`The app '${nombreDoc}' was last reloaded at:${appInfo.qLastReloadTime}`);
session.close();
console.log(`Closing the session`);
})().catch(err => {
console.error(err);
});
@willenjs when connecting through the Qlik Sense Proxy the closed sockets are quarantined for some time before they can be "re-used". This is for preventing misusage of the license model. I'm not sure what the "cool-down" time is for closed connections.
If you need more connection simultaneous you could use certificates and connect directly to the engine
Thank you very much @axelssonHakan . The default 'cool-down' seems to be something around ~5 mins. I will definitely change it to certificates or jwt?.
Marking this as resolved and closing issue
it worked very well
/* eslint import/no-unresolved:0, import/extensions:0, no-console:0 */
const enigma = require('enigma.js');
const WebSocket = require('ws');
const schema = require('enigma.js/schemas/12.20.0.json');
const path = require('path');
const fs = require('fs');
//process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
var args = process.argv.slice(2)
var urlws = args[0];
var nombreDoc = args[1];
var userDir = args[2];
var userId = args[3];
var certPath = args[4];
var session = enigma.create({
schema,
url: urlws,
createSocket: url => new WebSocket(url, {
ca: fs.readFileSync(path.resolve(certPath, 'root.pem')),
cert: fs.readFileSync(path.resolve(certPath, 'client.pem')),
key: fs.readFileSync(path.resolve(certPath, 'client_key.pem')),
headers: {
'X-Qlik-User': `UserDirectory=${encodeURIComponent(userDir)}; UserId=${encodeURIComponent(userId)}`,
},
}),
});
(async () => {
const global = await session.open();
const docList = await global.getDocList();
console.log(docList);
docId = docList.filter(obj => obj.qTitle == nombreDoc)[0].qDocId;
console.log(`\nStarting to RELOAD the app ${nombreDoc} with docId=${docId}`);
const app = await global.openDoc(docId);
console.log('\t- Opening the app');
await app.doReload();
console.log('\t- Reloading the app');
await app.doSave();
console.log('\t- Saving the app');
const appInfo = await app.getAppProperties();
console.log(`The app ${nombreDoc} was last reloaded at:${appInfo.qLastReloadTime}`);
session.close();
console.log('Closing the session');
})().catch(err => {
console.error(err);
});
i just made a small changes to your code.
And found that the problem the "socket hang up" is more that the certificates are not longer working outside of the server... is more a configuration of the server problem.
Description
I been working in a Script that allows the reload of an app under petition, but im getting a "socket hang up". error:
Steps to Reproduce
Script Used:
Is called from a console using this command:
Expected behavior
This must uptate the apication.
Actual behavior
Environment
Library
Operating system
Qlik Sense
Versions