Getting http status as 0 - connection timeout while trying to reach an endpoint through midserver
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-06-2022 06:43 AM
Hi Everyone, I am trying an integration between ServiceNow and a 3rd party tool, I have an attachment for which I have to convert it into base 64 and pass that as requestbody to the external system, I am also using a mid server to establish a connection between the two, but when I try to run the script I am getting connection timeout error, below is the script kindly help if anybody knows, thanks
try {
var tableSysID = 'b001103c87145510be851f083cbb352f';
var att = new GlideRecord('sys_attachment');
att.addQuery('table_name', 'sn_bom_mortgage_loan_request');
att.addQuery('table_sys_id', tableSysID);
att.query();
if (att.next()) {
var StringUtil = new GlideStringUtil();
var sa = GlideSysAttachment();
var binData = sa.getBytes(att);
var encData = StringUtil.base64Encode(binData);
var body = {
"file": encData
};
gs.info(JSON.stringify(body,null,1))
var r = new sn_ws.RESTMessageV2('dummpy api', 'dummy api);
r.setRequestBody(JSON.stringify(body));
r.setHttpTimeout("5000");
r.setMIDServer('MyMidserver');
// r.setRequestBodyFromAttachment(att.getUniqueValue());
// r.setRequestBody("Accept","application/json");
// r.setRequestBody("Content-Type",att.content_type);
// var response = r.execute();
// response.waitForResponse(60000);
var response = r.executeAsync();
response.waitForResponse(180);
var responseBody = response.getBody();
var httpStatus = response.getStatusCode();
gs.info('http Status' + httpStatus);
gs.info("Data :" + responseBody);
}
}catch (ex) {
var message = ex.message;
}
- Labels:
-
Integrations

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-06-2022 07:01 AM
Check whether your MID server has connectivity to this URL.
Thank you,
Palani
Palani
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-07-2022 03:08 AM
Yes, it's reaching the url.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-22-2022 11:22 AM
Same problem here. Although the requests get executed properly on the target, ServiceNow is returning a false timeout. Already tried setting higher timeouts, deactivating timeouts via sys_property and many other things, but nothing seems to work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-30-2023 07:36 AM
HI @Sven Betzel
Have you resolved this ?
Same error facing here also , can you please help me on this