View Issue Details

IDProjectCategoryView StatusLast Update
0002258XdebugStep Debuggingpublic2024-07-17 18:14
Reportermarcus90 Assigned Toderick  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionnot fixable 
Product Version3.2.2 
Summary0002258: Cannot enable step debugging with remote Docker container
Description

Hello,

I cannot make step debugging working in a remote Docker container.
If I check the xdebug logs I see: The debugging client closed the connection on socket 8: Broken pipe (error: 32).

I tried with Xdebug 3.0, 3.1, 3.2 and 3.3 with no success.

Steps To Reproduce

OS: Ubuntu 22.04.4 LTS
Docker: Docker version 25.0.3, build 4debf41

docker-compose.yml:

version: '3.5'

services:
  nginx:
    image: 'nginx:1.21-alpine'
    container_name: '${DOCKER_STACK}_nginx'
    restart: always
    working_dir: /var/www
    volumes:
      - './../:/var/www'
      - './docker/nginx.conf:/etc/nginx/conf.d/default.conf'
    networks:
      - default
      - web
  fpm:
    build:
      context: ./docker
      dockerfile: fpm-bullseye.dockerfile
    container_name: '${DOCKER_STACK}_fpm'
    extra_hosts:
      - "host.docker.internal:host-gateway"
    ports:
      - "9003:9003"
    restart: always
    working_dir: /var/www
    env_file: .env
    volumes:
      - './../:/var/www'
      - './docker/xdebug.ini:/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini'
      - './docker/error_reporting.ini:/usr/local/etc/php/conf.d/error_reporting.ini'
    networks:
      - default

xdebug.ini:

zend_extension=xdebug

[xdebug]
xdebug.mode=develop,debug
xdebug.client_host=host.docker.internal
xdebug.start_with_request=yes
xdebug.log=/tmp/xdebug.log
xdebug.log_level=10

error_reporting.ini:

error_reporting=E_ALL

nginx.conf:

server {
    listen      80;
    listen      [::]:80;
    root        /var/www/public;
    index       index.php index.html;

    gzip on;
    gzip_disable "MSIE [1-6]\.(?!.*SV1)";
    gzip_types application/json application/xml application/x-javascript application/javascript text/javascript text/css;
    gzip_vary on;

    add_header X-Content-Type-Options "nosniff";
    add_header X-Frame-Options "SAMEORIGIN";

    client_max_body_size 4m;

    location = /favicon.ico {
        return 204;
        access_log off;
        log_not_found off;
    }

    location ~* \.(js|css|png|jpe?g|gif|ico|svg|woff|woff2)$ {
        expires 30d;
        access_log off;
        log_not_found off;
    }

    location / {

        try_files $uri $uri/ /index.php?$args;

        location ~ \.php$ {
            include        fastcgi_params;
            fastcgi_pass   fpm:9000;
            fastcgi_index  index.php;
            fastcgi_param  PHP_VALUE  "expose_php=0
                memory_limit=128M
                post_max_size=16M
                upload_max_filesize=16M
                max_execution_time=60
                max_input_time=60
                log_errors=On
                error_log=/dev/stderr";
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_param PATH_INFO $fastcgi_path_info;
            fastcgi_param SERVER_NAME $host;
        }
    }
}

Dockerfile:

FROM php:8.0.29-fpm-bullseye

RUN apt-get update -y && \
    apt-get -y install --no-install-recommends whiptail libtidy-dev apt-utils libicu-dev git gcc make autoconf libc-dev pkg-config libzip-dev
#    # Xdebug
RUN pecl install xdebug-3.2.2 && docker-php-ext-enable xdebug
    # Cleanup
RUN apt-get remove -y git && \
    apt-get autoremove -y && \
    apt-get clean && \
    rm -rf /etc/cron.*/* && \
    rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
    # Cron hack
RUN touch /tmp/run_scheduler
Additional Information

/tmp/xdebug.log (after accessing an endpoint via Postman or browser):

[7] Log opened at 2024-03-31 10:54:28.922484
[7] [Step Debug] INFO: Connecting to configured address/port: host.docker.internal:9003.
[7] [Step Debug] INFO: Connected to debugging client: host.docker.internal:9003 (through xdebug.client_host/xdebug.client_port).
[7] [Step Debug] -> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" fileuri="file:///var/www/public/index.php" language="PHP" xdebug:language_version="8.0.30" protocol_version="1.0" appid="7"><engine version="3.2.2"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[https://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2023 by Derick Rethans]]></copyright></init>

[7] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" status="stopping" reason="ok"></response>

[7] [Step Debug] WARN: The debugging client closed the connection on socket 8: Broken pipe (error: 32).
[7] Log closed at 2024-03-31 10:54:28.968976

Doing telnet 127.0.0.1 9003 gives the following output:

Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
Connection closed by foreign host.

I can telnet successfully on port 9003 if assigned to an nginx container for example so there is no firewall issue.

TagsNo tags attached.
Attached Files
xdebug.png (513,537 bytes)
Operating SystemUbuntu 22.04.4 LTS
PHP Version8.0.20-8.0.29

Activities

derick

2024-04-15 12:40

administrator   ~0006900

The debugger connected correctly to your IDE, and after that, Xdebug sent the <init packet.
Your image also shows that a connection was made.
It is really the IDE that closed the connection here, so you will need to check in the logs on that side, what is going on. You didn't say which one it is, so can't point you further towards having a look there.

derick

2024-05-06 10:25

administrator   ~0006938

Can you provide the requested feedback please?

marcus90

2024-05-09 18:24

reporter   ~0006950

The IDE is PhpStorm v2021.2.2. I attached a screenshot with the config.

Can you provide the requested feedback please?
I don't think I know how to do this. Can you help me ?

Thank you!

phpstorm_xdebug_config.png (93,801 bytes)   
phpstorm_xdebug_config.png (93,801 bytes)   

derick

2024-05-10 15:16

administrator   ~0006951

You're going to have to take this up with JetBrains' support for PhpStorm them. I don't know how to make it create logs as to where it terminated the connection.

marcus90

2024-05-11 07:26

reporter   ~0006956

Thank you for your feedback. I will open a ticket with them.

derick

2024-06-05 09:59

administrator   ~0006966

If you have their ticket number, feel free to add it here. I would want to close this ticket as "Can't Fix" as it's unlikely to be a bug here.

Issue History

Date Modified Username Field Change
2024-03-31 11:07 marcus90 New Issue
2024-03-31 11:07 marcus90 File Added: xdebug.png
2024-04-15 12:40 derick Assigned To => derick
2024-04-15 12:40 derick Status new => feedback
2024-04-15 12:40 derick Note Added: 0006900
2024-05-06 10:25 derick Note Added: 0006938
2024-05-09 18:24 marcus90 Note Added: 0006950
2024-05-09 18:24 marcus90 File Added: phpstorm_xdebug_config.png
2024-05-09 18:24 marcus90 Status feedback => assigned
2024-05-10 15:16 derick Status assigned => feedback
2024-05-10 15:16 derick Note Added: 0006951
2024-05-11 07:26 marcus90 Note Added: 0006956
2024-05-11 07:26 marcus90 Status feedback => assigned
2024-06-05 09:59 derick Status assigned => feedback
2024-06-05 09:59 derick Note Added: 0006966
2024-07-17 18:14 derick Status feedback => resolved
2024-07-17 18:14 derick Resolution open => not fixable