1

I am keep getting this error in Xdebug log:

Time-out connecting to client (Waited: 200 ms). :-(

And debugger in PhpStorm is not working at all.

$ php -v
PHP 7.3.21 (cli) (built: Aug  4 2020 11:21:19) ( ZTS MSVC15 (Visual C++ 2017) x64 )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.21, Copyright (c) 1998-2018 Zend Technologies
    with Xdebug v2.9.6, Copyright (c) 2002-2020, by Derick Rethans

My PHP Ini:

[xdebug]
zend_extension=".../php_xdebug-2.9.6-7.3-vc15-x86_64.dll"
xdebug.profiler_append=0
xdebug.profiler_enable=1
xdebug.profiler_enable_trigger=0
xdebug.profiler_output_dir = ".../tmp"
xdebug.profiler_output_name = "xdebug_profile.%R::%u"
xdebug.remote_enable=On
xdebug.remote_handler=dbgp
xdebug.remote_host=127.0.0.1
xdebug.remote_mode=req
xdebug.remote_port=9001
xdebug.auto_trace=1
xdebug.collect_includes=1
xdebug.collect_params=1
xdebug.idekey=PHPSTORM
xdebug.remote_autostart=1
xdebug.remote_log=".../logs/xdebug.log"
;xdebug.remote_connect_back=1

Log out:

==> xdebug.log <==
[17080] Log opened at 2021-02-18 20:10:25
[17080] I: Connecting to configured address/port: 127.0.0.1:9001.
[17080] E: Time-out connecting to client (Waited: 200 ms). :-(
[17080] Log closed at 2021-02-18 20:10:25

PhpStorm Debug Settings:
settings

LazyOne
  • 158,824
  • 45
  • 388
  • 391
Mehmet Bayrak
  • 11
  • 1
  • 3
  • You have "Can accept external connection" option disabled. Check what it does: https://www.jetbrains.com/help/phpstorm/2020.3/debug.html – LazyOne Feb 18 '21 at 20:35
  • Thank you for your reply. I changed it. It stops at the first line of the code but don't let me move on. Process has been frozen up entirely after hit on F8. after I clicked on red square (stop) icon then it moves on and finishes it without stopping on other breakpoints. It seems to me it is related to xdebug.remote_handler=dbgp. Since it is giving me "timeout" error, I wonder myself it might be about local proxy settings. – Mehmet Bayrak Feb 18 '21 at 21:51
  • 1) `xdebug.remote_handler` -- does nothing since 2.9.0 -- see https://stackoverflow.com/a/63209405/783119 2) "Your "freezes" description does not say much to me. But try increasing "max simultaneous connections" to 3. 3) You have profiler and debugger enabled at the same time -- it makes little sense to have them both at the same time. 4) I would suggest to upgrade your IDE to the latest 2020.3.2 version (if you cannot upgrade then at least try how it works there). – LazyOne Feb 18 '21 at 22:41
  • 5) You may disable "Break at first line in PHP Scripts" and other 2 "Force break..." options and see how it will behave. If it does not stop anymore then you have some path mapping issue etc. – LazyOne Feb 18 '21 at 22:43

1 Answers1

5

In search, I got to the point that something was blocking the request from the docker to the local machine on port 9000 9003. In the end, I solved the problem by adding new 2 rules to the ubuntu ufw firewall and it all worked.

sudo ufw allow in from 172.16.0.0/12 to any port 9000 comment xDebug9000
sudo ufw allow in from 172.16.0.0/12 to any port 9003 comment xDebug9003

Specifically, you need to open port 9001. As in the examples above. Also, instead of localhost in xdebug.client_host, I specified my IP on the local network.

Address:   172.16.0.0            10101100.0001 0000.00000000.00000000
Netmask:   255.240.0.0 = 12      11111111.1111 0000.00000000.00000000
Wildcard:  0.15.255.255          00000000.0000 1111.11111111.11111111
=>
Network:   172.16.0.0/12         10101100.0001 0000.00000000.00000000 (Class B)
Broadcast: 172.31.255.255        10101100.0001 1111.11111111.11111111
HostMin:   172.16.0.1            10101100.0001 0000.00000000.00000001
HostMax:   172.31.255.254        10101100.0001 1111.11111111.11111110
Hosts/Net: 1048574               (Private Internet)
Dharman
  • 30,962
  • 25
  • 85
  • 135
Slashere
  • 51
  • 3
  • instead of your local IP, you can use `host.docker.internal`, which has to be mapped first to `host-gateway` in docker to work under linux: https://stackoverflow.com/a/67158212/2346308 – Fabian Horlacher May 09 '22 at 14:56
  • This turned out to be my problem as well, although in my case it was due to a new version of ESET antivirus in Windows. I had to specify a manual firewall rule to allow connections in from 9003 with the appropriate IP, but after that it worked. – Clonkex Jan 13 '23 at 03:57