0

I am trying to debug using NetBeans 11 as my client, Xdebug 3 on the Docker image. The Docker container is on a remote host. I am unable to make a connection. Indicator at the bottom of the NetBeans screen scrolls forever with "waiting for connection (netbeans-xdebug)". I am not sure what I am doing wrong. I have had this work in the past without Docker and with Xdebug 2, I am not sure if I messed up the Xdebug 3, the Docker or both.

My configurations:

Dockerfile adds Xdebug properly and I can see it in my container.

docker-compose.yml

---

services:
  drupal:
    container_name: intranet-finkenb2
    ports:
      - "8082:80"
      - "9092:9003"
    volumes:
      - /home/finkenb2/intranet/custom_themes:/opt/drupal/web/themes/custom
      - /home/finkenb2/intranet/custom_modules:/opt/drupal/web/modules/custom
    environment:
      XDEBUG_MODE: debug,develop
      XDEBUG_SESSION: netbeans-xdebug
      XDEBUG_CONFIG: >
        client_host = localhost
        client_port = 9003
        discover_client_host=true
        start_with_request=yes
  db:
    container_name: intranet-finkenb2-db
  solr:
    container_name: intranet-finkenb2-solr
    ports:
      - "8982:8983"

volumes:
  public_files:
  private_files:
  site_settings:

SSH Tunnel via PuTTY: R9092 localhost:9092

NetBeans PHP Debug config:

 - Debugger Port: 9092
 - Session ID: netbeans-xdebug
 - Maximum Data Length: 8192
 - Check: Stop at first line

NetBeans Project config (run configuration):

 - Run As: Remote Web Site
 - Project URL: http://intranet-finkenb2.devel.lib.msu.edu
 - index file: index.php
 - remote connection
   - hostname intranet8.devel.lib.msu.edu /*docker host server*/
   - user/pwd correct
   - initial directory /var/www/
LazyOne
  • 158,824
  • 45
  • 388
  • 391
  • 1) It's Xdebug that connects to IDE (makes the connection) and NOT other way around. 2) This is for PhpStorm, but overall idea is exactly the same: https://www.jetbrains.com/help/phpstorm/remote-debugging-via-ssh-tunnel.html 3) Also check https://stackoverflow.com/questions/62580411/how-to-reverse-ssh-tunnel-to-remote-docker-container-for-xdebug – LazyOne May 24 '21 at 14:04

1 Answers1

1

This is not correct:

ports
- "9092:9003"

Xdebug connects to your IDE, so you don't need to expose the port. These ports are for external exposures anyway, and you're SSH-ing into the container with -R already, so this makes no sense.

This is not correct:

  XDEBUG_CONFIG: >
    client_host = localhost
    client_port = 9003
    discover_client_host=true
    start_with_request=yes
  1. You can't use all of these as part of the XDEBUG_CONFIG variable, start_with_request, for example.
  2. discover_client_host with Docker doesn't work, as it gets the wrong IP through the gateway
  3. localhost is normally also not correct, as it needs to be the IP/hostname of the machine where your IDE listens. But you're SSH-ing into that container, so that should fine fine.
  4. With that SSH tunnel, you need to set client_port to the port of your remote SSH end point (9092).

If anything else is unclear, make a log file, or try to debug a page with xdebug_info() in it, and it will tell you what Xdebug has tried.

Derick
  • 35,169
  • 5
  • 76
  • 99