# Socket hang up error

**URL:** <https://community.postman.com/t/socket-hang-up-error/13423>\
**Category:** Help Hub\
**Tags:** newman-project, tests, collections\
**Created:** [June 15, 2020, 6:35pm UTC](https://community.postman.com/t/socket-hang-up-error/13423 "2020-06-15T18:35:54Z")\
**Posts on this page:** 1\
**Showing post:** 11

<div class="post-metadata">

**Author:** ![amit](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/amit/32/2056_2.png) [@amit](https://community.postman.com/u/amit)\
**Post date:** [August 4, 2020, 4:36am UTC](https://community.postman.com/t/socket-hang-up-error/13423/11 "2020-08-04T04:36:54Z")

</div>

Here is cleaner solutions using `async/await`:

```
// Set this to some high value
// current value 300000 = 5 minutes, which should be good in most cases!
const _dummy = setInterval(() => {}, 300000);

function performRequest(url) {
   return new Promise( (resolve) => { pm.sendRequest(url, (err, res) => {

            // We are not checking for errors
            // If you want you can read the err object to do do some error handling

            setTimeout((res) => { return resolve(res); }, 2000); // Wait for 2 seconds before returning the result.

            // if no delay is required remove the above line and uncomment the following
            // return resolve(res);
        });
   });
}

// I haven't defined requestList in this example, it should be set as described in the previous post
(async function () {
    for(let idx = 0; idx < requestList.length; idx++) {
        console.log("Calling:", requestList[idx]);

        let response = await performRequest(requestList[idx]);

        console.log("response:", response);
    }
    
    clearInterval(_dummy);
}) ();
```

---

_[View the full topic](https://community.postman.com/t/socket-hang-up-error/13423)._
