Avoid Proxy for HttpClientRequest - IOB-090007 Network error (send(), errno=10054: an existing connection was forcibly closed by the remote host

This is Friday night 8:10 PM and I was frustratingly stuck with an annoying issue on something that I have done so many times, but still unable to figure out what is wrong since last night. Finally it was a silly mistake and I found that. So wanted to capture it so that I don't need to spend another day and half just to figure out why the same thing is not working
I was making a call to Silverpop XMLAPI to get the jessionid via the login method. And the code is something like below, very basic one
var http = new HttpClientRequest("http://api2.ibmmarketingcloud.com/XMLAPI");
try {
http.method = 'POST';
http.header["ClientId_Internal"] = "XYZABCD";
http.header["ClientSecret_Internal"] = "DSFDSOFNJSDF";
http.header["Content-Type"] = "application/x-www-form-urlencoded";
var reqestBody = "xml=" + encodeURIComponent("<Envelope><Body> <Login> <USERNAME>TarunGhosh</USERNAME> <PASSWORD>ThisIsMyPass</PASSWORD> </Login> </Body></Envelope>");
var buffer = new MemoryBuffer();
buffer.fromString(reqestBody);
http.body = buffer;
http.execute();
var rsp = http.response;

switch (rsp.code) {
case 200:
/*
<Envelope>
<Body>
<RESULT>
<SUCCESS>true</SUCCESS>
<SESSIONID>C716F5129FEA5FD368A92CEB58DDFB5B</SESSIONID>
<ORGANIZATION_ID>1764a75-1230f76e998-df4cba773885eb54dfcebd294a039c37</ORGANIZATION_ID>
<SESSION_ENCODING>;jsessionid=C716F5129FEA5FD368A92CEB58DDFB5B</SESSION_ENCODING>
</RESULT>
</Body>
</Envelope>
*/
var responseDOM = DOMDocument.fromXMLString(rsp.body.toString(rsp.codePage));
var sessionElements = responseDOM.getElementsByTagName("SESSIONID");
var sessionId = "";
for each(var element in sessionElements)
{
logInfo("Element:" + element.toXMLString());
sessionId = element.getValue(".");
break;
}
return sessionId;
default:
logError("Error when calling " + this.XMLAPIEndPoint + " - Error Code:" + rsp.code + ": " + rsp.body.toString(rsp.codePage));
}
}
catch (e) {
var error = e.toString();
logError("Error:" + error);
}
finally {
//http.dispose();
}

But I was getting an error
09/06/2019 8:04:08 PM Response Code:200, Encoding:1252, Message:Connection established
09/06/2019 8:04:08 PM IOB-090007 Network error (send(), errno=10054: an existing connection was forcibly closed by the remote host.)

So I decided to try a power shell (yes windows server) script from inside the server and check what the hell is happening.
So I wrote something similar to below
$headers = @{}
$headers.Add("ClientId_Internal","XYZABCD")
$headers.Add("ClientSecret_Internal","DSFDSOFNJSDF")
$body = @{xml="<Envelope><Body> <Login> <USERNAME>TarunGhosh</USERNAME> <PASSWORD>ThisIsMyPass</PASSWORD> </Login> </Body></Envelope>"}
$contentType = 'application/x-www-form-urlencoded'
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true} ;
Invoke-WebRequest -Uri "http://api2.ibmmarketingcloud.com/XMLAPI" -Headers $headers -Method POST -ContentType $contentType -body $body

And I got proper response. So it is not a networking issue. After spending some time on forum, I got some response on proxy and it was like switching on the bulb inside your brain :D
Now I recalled that I have a proxy enabled in the serverConf.xml file. But this connection has to bypass the proxy. So I added the URL into the proxy as below and BOOM!!! I got the reponse

<proxyConfig enabled="1" override="localhost*,api2.ibmmarketingcloud.com*" useSingleProxy="0">

I did this while AEM, AA, Salesforce and other integrations and still I forgot this. What nonsense..

Comments

Popular posts from this blog

Adobe Campaign: Call Java Script from Input Form

Broadlog Resequencing in Adobe Campaign Classic