1

I have a strange problem when trying to debug with Xdebug on Netbeans ( on Windows 8 ) a curl request. Here is my code:

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, "http://localhost");
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_TIMEOUT, 10);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);

    $response = curl_exec($ch);
    if ( curl_errno($ch) ) {
        $result = 'ERROR -> ' . curl_errno($ch) . ': ' . curl_error($ch);
        echo $result;
    }

    print "\n response = \n";
    var_dump($response);

    // close cURL resource, and free up system resources
    curl_close($ch);

    die;

When I debug with Netbeans I get:

ERROR -> 28: Operation timed out after 10015 milliseconds with 0 out of -1 bytes  receivedresponse = bool(false)

When I just run without debug I get no error and a response of a xampp page.

In php.ini I have:

[XDebug]
zend_extension = "C:\xampp\php\ext\php_xdebug-2.2.5-5.4-vc9.dll"
xdebug.profiler_append = 0
xdebug.profiler_enable = 1
xdebug.profiler_enable_trigger = 0 
xdebug.profiler_output_dir = "C:\xampp\tmp"
xdebug.profiler_output_name = "cachegrind.out.%t-%s"
xdebug.remote_enable = 1
xdebug.remote_handler = "dbgp"
xdebug.remote_autostart = 1
xdebug.remote_host = "127.0.0.1"
xdebug.remote_port = "9000"
xdebug.trace_output_dir = "C:\xampp\tmp"
xdebug.max_nesting_level = 200
xdebug.idekey = "netbeans-xdebug"
danpop
  • 967
  • 13
  • 25

1 Answers1

5

I suppose that when you set xdebug.remote_autostart = 1, Xdebug will always attempt to start a remote debugging session and try to connect to a client (even if the GET/POST/COOKIE variable was not present).

May be, in your case, Xdebug try to connect Netbeans but is unable to complete the operation, which this lead Xdebug to Operation timeout error.

freedev
  • 25,946
  • 8
  • 108
  • 125
  • I think you have a point. I modified the php.ini to this and it seems to work [XDebug] zend_extension = "C:\xampp\php\ext\php_xdebug-2.2.5-5.4-vc9.dll" ;xdebug.profiler_append = 0 ;xdebug.profiler_enable = 1 ;xdebug.profiler_enable_trigger = 0 ;xdebug.profiler_output_dir = "C:\xampp\tmp" ;xdebug.profiler_output_name = "cachegrind.out.%t-%s" xdebug.remote_enable = 1 xdebug.remote_handler = "dbgp" ;xdebug.remote_autostart = 1 xdebug.remote_host = "127.0.0.1" xdebug.remote_port = "9000" ;xdebug.trace_output_dir = "C:\xampp\tmp" xdebug.max_nesting_level = 200 xdebug.idekey = "netbeans-xdebug" – danpop May 14 '14 at 11:10
  • @danpop as far as I see in your comment `xdebug.remote_autostart` still is set to `1`. May be a typo? – freedev May 14 '14 at 12:28
  • It has a semicolon in front of it, so it's commented out. The clean configuration is this: zend_extension = "C:\xampp\php\ext\php_xdebug-2.2.5-5.4-vc9.dll" xdebug.remote_handler = "dbgp" xdebug.remote_host = "127.0.0.1" xdebug.remote_port = "9000" xdebug.max_nesting_level = 200 xdebug.idekey = "netbeans-xdebug" – danpop May 14 '14 at 12:58
  • this work thanks a lot. the break point doesn't stop at the curl request but if there is breakpoint in the file the curl is hitting it doesn't go there. – Naseeruddin V N Oct 08 '17 at 07:11
  • @NaseeruddinVN, xdebug would not know how to follow a curl request. What if your curl is hitting an external API? how would xdebug obtain source let alone break somewhere along it? Consider curl a point of departure for debugging. – eggmatters Dec 21 '17 at 18:50