Score:0

Random unexpected connection errors while fetching data

pw flag
Leo

I am having a really weird problem with my VPS (Centos 7) for the last 2 days. I have an application where I fetch data from dozens of 3rd party websites. For the past 2 years everything was working fine - until 2 days ago. I noticed that suddenly (some) outbound connections started failing. I started receiving "Connection timed out" or "HTTP connection failed" type of errors. This is a server-wide issue, not just about a domain or folder. I need to note that my server IP is NOT blocked by the target websites, I am authorized to fetch this data. There was also NO change with the code or the server software before this started. I even hired a full-stack Linux admin and even he couldn't figure out what this is. He tried updating PHP configuration, changing PHP version, checked the resolv DNS and all but he couldn't figure it out. I also contacted my hosting provider and they told me the VPS is working fine on their end.

Today I tried something different. I have tried using cURL through a proxy connection and it worked just fine, no errors. Again, I confirmed that my IP is not blocked anywhere. The connection errors are random, not specific to some websites, sometimes a failed target succeeds on the next try. There's a very irregular pattern with failed connections, when I try to fetch, say 20 websites, it goes like this: (Good is 1, Failed is 0) -> 1,1,1,0,0,1,1,1,0,1,1,0,0,1,1,1,0,1,1,1,0,0,0,1,1,1,0,1

This issue is more significant if the request I send is large, as in, if I send some post header data too and I should receive a sizeable response from the target server, it fails a lot more frequently than just fetching a page with file_get_contents or a simple cURL. As I said: There is no IP blocking issue, no rate limiting issue, everything works fine with proxy, but not with server IP. I have no idea what interrupts my connections here and there.

What may be the cause of this problem? How can I diagnose why the connections really fail when they do? Any input is highly appreciated.

Matthew Ife avatar
jo flag
Given the intermittent nature of the problem I'd suggest you start by recording packet traces of the issue whereby one trace records what happens when a problem hits and another trace records what happens when it doesn't. Preferably to the same destination.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.