• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Client opened session with ID 1 but the SOAP header targets session with ID 2!

New Here ,
Aug 14, 2017 Aug 14, 2017

Copy link to clipboard

Copied

We are calling IDS from a nodejs app using the "node-soap" component.  We are now introducing sessions and encountering the issue.

I just stared a session and tried to close it. Always get error message inside the event soapError saying "Client opened session with ID 1 but the SOAP header targets session with ID 2!" .If I try to run it again I get error "Client opened session with ID 1 but the SOAP header targets session with ID 3!". Tried runscript() also , It ran successfully but still get the error message.

I use indesign server 2015.

Please see the code which I use,

var soap = require("soap");

var url = "http://localhost:8194/wsdl?wsdl";

var args = { "IDSP:runScriptParameters":

{

"scriptLanguage": "javascript",

"scriptFile": scriptPath,

"IDSP:scriptArgs" : [

{ "IDSP:name" : "user",

"IDSP:value" : thisUser}

]

}

};

soap.createClient(url, function(err, client) {

client.on("soapError", function(err) {

console.log(err.message);

return errDataCallback(soapErr);

});

var sessionId;

client.BeginSession(function(err,session,test1){

sessionId = session.sessionID;

console.log("sessionID : "+sessionId);

if(err){

return errDataCallback(err);

}

var result = client.addSoapHeader({"sessionID":sessionId},"sessionID","IDSP","");

var sessionArg = { "IDSP:sessionID": sessionId.toString()};

client.EndSession(sessionArg, function(err){

console.log(err.message);

});

});

});

Please help me to resolve the issue.

Views

1.1K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Beginner , Oct 21, 2019 Oct 21, 2019

Ok I finally figure it out.

The issue is that IDS attach in some way a socket to a session.

So whenever the socket is closed, the session is closed as well.

The trick in nodejs is to create a custom http.Agent you pass to your http request for each session you want to be maintained with (for example) those params :

let keepAliveAgent = new http.Agent({
            keepAlive: true, // so the socket is not closed after http request completion (do not forget to do a request.end() after your request.wri
...

Votes

Translate

Translate
Community Expert ,
Aug 14, 2017 Aug 14, 2017

Copy link to clipboard

Copied

Moving to InDesign Server Developers Forum

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 18, 2017 Aug 18, 2017

Copy link to clipboard

Copied

Anybody worked with Indesign server + node js.

Is there anyone form Adobe team to help with ?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 01, 2019 Oct 01, 2019

Copy link to clipboard

Copied

Hi, I have exactly the same problem. Did you solve it ?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 21, 2019 Oct 21, 2019

Copy link to clipboard

Copied

LATEST

Ok I finally figure it out.

The issue is that IDS attach in some way a socket to a session.

So whenever the socket is closed, the session is closed as well.

The trick in nodejs is to create a custom http.Agent you pass to your http request for each session you want to be maintained with (for example) those params :

let keepAliveAgent = new http.Agent({
            keepAlive: true, // so the socket is not closed after http request completion (do not forget to do a request.end() after your request.write())
            keepAliveMsecs:600000, // set to enough time to not have the connection timed out
            maxSockets:1 // ensure that the Agent does not open an other parralell socket
        });

Then for each http request you create to be executed within the session (including the beginSession and endSession) you pass that Agent as parameter :

RequestOptions = {
            hostname: server.hostname,
            port: server.port,
            path: server.path,
            method: 'POST',
            headers: {
                'Content-Type': 'text/xml;charset=UTF-8',
                'Content-Length': Buffer.byteLength(postData),
                'Connection': 'Keep-Alive',
                'SOAPAction':'""'
            },
            agent:keepAliveAgent
}

 For any new session, you just create a new http.Agent ...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines