0

I just upgraded PHP from 7.2 to 7.4, but I noticed that PHP cURL Proxy is not working in 7.4.

Here is the code I am using:

<?php

$Socks5Proxy = 'socks5://127.0.0.7:1080'; //example proxy


    $ch = curl_init();
    curl_setopt ($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_PROXY, $Socks5Proxy);
    curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5_HOSTNAME);
    curl_setopt($ch, CURLOPT_POST, false);
    curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
    curl_setopt($ch, CURLOPT_ENCODING, 'gzip');
    curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.246');
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($ch, CURLOPT_HEADER, false);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_VERBOSE, 0);
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
    curl_setopt($ch, CURLOPT_TIMEOUT, 20);
    $data = curl_exec($ch);
    curl_close($ch);
?>
Roberto Caboni
  • 7,252
  • 10
  • 25
  • 39
Santhosh Veer
  • 83
  • 1
  • 3
  • 13
  • 2
    First of all, an error message would help us identify the problem. If you don't get any logs, using ``curl_errno($ch)`` after the curl_exec($ch) will give you an error number. Second, did you also update the cURL extension? – Realitätsverlust May 27 '20 at 09:41
  • it gives `28` and `Connection timed out after 5001 milliseconds` PHP curl module already in the latest version – Santhosh Veer May 27 '20 at 09:47
  • Can you send curls to other URLs? Or is it only your socket that shows this problem? – Realitätsverlust May 27 '20 at 10:06
  • yes getting this issue while connecting via socks5 proxy No issue on Direct URL calling – Santhosh Veer May 27 '20 at 10:10
  • Well, that makes debugging very hard. Did you update socks5 to the latest version too? Maybe it's incompatible with PHP7.4. If you did, you should create an issue on github for this, they are more likely able to help you than we are since this is a very specific problem. – Realitätsverlust May 27 '20 at 10:20
  • I improved the question by fixing some typos. I suggest incorporating in the question all the additional info that is being posted in comments, so that the question becomes more detailed and complete. – Roberto Caboni May 27 '20 at 13:28

0 Answers0