Getting http status as 0 - connection timeout while trying to reach an endpoint through midserver

anu20
Giga Contributor

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;

        }

4 REPLIES 4

palanikumar
Giga Sage

Check whether your MID server has connectivity to this URL.

Thank you,

Palani

Thank you,
Palani

Yes, it's reaching the url.

Sven Betzel
Kilo Contributor

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.

HI @Sven Betzel 

Have you resolved this ?
Same error facing here also , can you please help me on this