Open ljerka opened 7 years ago
Hi @ljerka, not sure what you mean about keeping the connection open? This package uses request module's cookie jar to enable a session with the cms server. Any processing done in your handler after invoking login() will be done in same session. See snippet below...
var report = new Cms(serviceUrl, serviceNamespace, serviceUsername, servicePassword);
var qs = {
p_prmFromDate: '2016-01-01',
p_prmToDate: '2016-12-31',
p_prmDetailOn: 'No',
fmt: 'HTMLFragment'
};
// logon returns a promise
report.logon().then(function(response){
// unfortunately cms api returns an Ok status of 200 on failed logins, but response has details of "SERVICE.COGNOSACCT.FAIL"
console.log(response.statusCode, response.body);
// even on unsuccessful login you may attempt to retrieve a report
report.getReportById(reportId, qs).then(function(response){
if (response.statusCode >= 400) {
// status code would be 403 if not authorized, see response.body for details
}
console.log(response.statusCode, response.body);
});
});
@nesbert I probably didn't explain it very good, sorry. Yes, report.logon()
opens the session, but my server is closing it after some period of time. I would like to be able to know weather the server closed the session, so I can logon again. Something like if (!report.active) { report.logon().then(...) }
.
@ljerka when you say closing connection. Do you mean CMS API is closing the session? We recently exposed some client settings based on a report that was taking a along time to run. See PR #4... the solution was to increase the max redirects for the request object. We made it so you are able to fine tune/override the default http request settings based user land needs.
I am attempting to understand more of your use case to see what solution maybe needed. If updating this setting fixes your issue please close this issue.
@nesbert yes, CMS API is set up to close the connection after 30min. So unfortunatelly PR #4 didn't fix this issue. I need a way to check if the connection is still open or was closed by CMS API.
I would like to keep my connection open and use it until automatic logout, but don't know how to check if I'm already logged in. Is there a way? Thanks.