0

I use a proxy server in PHP via curl or httpie.

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_PROXYPORT, 80);
curl_setopt($ch, CURLOPT_PROXYTYPE, 'HTTP');
curl_setopt($ch, CURLOPT_PROXY, $proxy_ip);
curl_setopt($ch, CURLOPT_PROXYUSERPWD, 'username:password');
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
$html = curl_exec($ch);
curl_close($ch);

When executing the script, the connection to the proxy server still exists. Thus, if running another script after 3s, the proxy authentication is refused because it has already connected somewhere else.

How can I fully disconnect from the proxy server by curl_close to make the proxy available for other scripts?

Googlebot
  • 15,159
  • 44
  • 133
  • 229
  • does this script take less than 3s to complete, or not? And does your proxy really only accept one concurrent connection per user?? – ADyson Feb 19 '18 at 14:45
  • @ADyson I meant 3s after finishing this script. No, if a connection is established with the server, the second one cannot get connected. – Googlebot Feb 19 '18 at 14:51
  • is that by design? It's very restrictive. curl_close should close the connection from the client's point of view, but whether the server is closing it properly, who knows. Isolate the problem - does the proxy work as expected if you do something involving it via browser? – ADyson Feb 19 '18 at 14:55
  • @ADyson I assumed this too. That's why I tried `httpie` too., but in either case, the connection remains open until being timeout from the server. For your reference, it is a paid service from nordvpn. – Googlebot Feb 19 '18 at 14:57
  • Is the cURL call sending a "keep-alive" header? – ADyson Feb 19 '18 at 14:57
  • https://en.wikipedia.org/wiki/HTTP_persistent_connection – ADyson Feb 19 '18 at 14:59

0 Answers0