Home » Php » php – Xdebug is always resetting session with phpStorm

php – Xdebug is always resetting session with phpStorm

Posted by: admin July 12, 2020 Leave a comment

Questions:

Ether my status never came cross before or I don’t know how to google it! my development environment got updated to ubuntu 14.04, phpStorm 2016.1 (still in trial version), java version “1.7.0_95”.
all settings are fine and I can debug, but after debugging start (a bout a minute or less), all debugging session gets terminates OR restarts from the first break point.
also I get a lot of “Debug Session was finished without being paused” notice without making any debug request (see attached plz).

enter image description here

please let me know what to check or what could be the reason.
Thanks in advance.


Update :

following is xdebug settings in php.ini

[xdebug] 
zend_extension="/usr/lib/php5/20121212/xdebug.so"
xdebug.default_enable=1
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.remote_autostart=1

development framework is magento 1.14.2 EE

How to&Answers:

You have the remote_autostart turned on, so every time you reload the page xDebug tries to debug the script, even if you weren’t meaning to.

According to the documentation

When this setting is set to 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.

Set xdebug.remote_autostart = 0 and that should stop the errant messages about debugging.

Answer:

I’ll quote a clear response from the official forums

You are right it’s fine to have debug session without any breakpoints reached, e.g. it’s common if you have Ajax request.
The warning is intend to help new users to configure debugger. If “Break at first line” option is disabled and there’s some error that silently prevent you to setup breakpoints (e.g. there’s a typo in path mappings at PHP|Servers, remote and local file versions are not synchronized, etc) then nothing will happen on page reload. This situation is indistinguishable from xdebug misconfiguration (e.g. wrong “xdebug.remote_host”, “xdebug.remote_port”) therefore you may spend a lot of time to figure out the problem. The message is saying that debugger itself is configured correctly and suggest you next step in troubleshooting process.

If you have no problem and debug session without breakpoints is expected behavior then just disable it

Answer:

Go to PHPStorm – Settings -> Languages & Frameworks -> PHP -> Debug

… Section “External connections” -> “Break at first line in PHP scripts” … disable this option

Additional suggestion:

… Section “Xdebug” -> disable the last two checkboxes (“Force break at first line…”)

… Section “Advanced settings” -> disable “Notify if debug session was finished without being paused”

Answer:

You mention that you use php_fpm, so try running

sudo service php5-fpm restart

Answer:

but after debugging start (a bout a minute or less), all debugging session gets terminates OR restarts from the first break point

I finally found a solution to this. My Apache configuration was set to terminate idle connections after 40 seconds – stopping the debug session and returning a 500 error to the client.

To fix this open your apache httpd.conf file and look for the following setting

LoadModule fcgid_module modules/mod_fcgid.so

If you are using this module, set or change the value of the following directive

FcgidIOTimeout 300

This setting defaults to 40 seconds if it is not specified, setting it to 300 will allow 5 minutes per connection before apache terminates it.

Answer:

most of other answers are valid, but in my case it was incompatibility between PHP version and Xdebug version.
so the solution for me was updating both PHP => PHP 7 & Xdebug to latest stable version.
I felt like it’s better to mention it in a separate answer in case anybody might come into same case.