Connection handling

Hi there,

I am adhering to the API rate limits so they are not exceeded but quite frequently in my application I get an ECONNRESET so Smarkets API are terminating my TCP connection. How my application works is that I fork many different NodeJS process’ to poll the markets of a single event. Due to this architecture, a new connection is created for every process. I didn’t want to overload the API with open connections so I pass the Connection: 'close' header with every request. As, by default, I can see that the response has the header Connection: 'keep-alive' unless specified specifically in the request. However, I was still getting the ECONNRESET error. I can see that another response header is Cache-Control: 'public, max-age=15'. How does this work if I attempting to close the connection? Is Smarkets still attempting to keep the connection open? If so, is there something else I can pass in my request to ensure that the connection is closed after every request? How long, by default, does Smarkets attempt to keep the connection open for?

Another idea I had was to put my own API in front of Smarkets to channel all requests through a single connection that to Smarkets that is kept alive, would this be better than than having loads of connections hitting your API & then dying? Below is the response headers I am getting when I request with Connection: 'close' header:

I appreciate this is a lot to answer so thank you for taking the time :slight_smile: