xdebug 3.0 wsl2和vscode -docker -proxy已经在使用地址

发布于 2025-01-30 12:26:15 字数 2156 浏览 5 评论 0 原文

我在WSL中的Vscode:Ubuntu无法收听Xdebug端口,因为它被某些Docker-Proxy挡住了。

我正在关注此解决方案收听Xdebug端口,会导致以下错误:

错误:听eaddrinuse:已使用的地址::: 9003

任何人可以帮助将VSCODE连接到Xdebug吗?

Windows 11说,该端口已经由WSLHOST分配:

PS C:\WINDOWS\system32> Get-Process -Id (Get-NetTCPConnection -LocalPort 9003).OwningProcess

Handles  NPM(K)    PM(K)      WS(K)     CPU(s)     Id  SI ProcessName
-------  ------    -----      -----     ------     --  -- -----------
    285      47     2288       4748       0,05  19480   1 wslhost

它是由某些Docker-Proxy分配的:

Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:9003            0.0.0.0:*               LISTEN      17210/docker-proxy
tcp6       0      0 :::9003                 :::*                    LISTEN      17217/docker-proxy

Docker-compose-version: Docker-Compose版本1.25.0 1.25.0

xdebug.log。

[Step Debug] INFO: Connecting to configured address/port: host.docker.internal:9003.
[Step Debug] ERR: Time-out connecting to debugging client, waited: 200 ms. Tried: host.docker.internal:9003 (through xdebug.client_host/xdebug.client_port) :-(

Ubuntu告诉, 只要什么都没听。

至于 xdebug.client_host 我尝试了:

  • host.docker.internal
  • xdebug:// gateway and> 引用以下内容:
  • 与Docker-compose.yml设置Env-

vAr如此注释也不会删除错误。

My VSCode in WSL:Ubuntu is unable to listen to the xdebug port, because it is blocked by some docker-proxy.

I was following this Solution, but trying VSCode to listen to the xdebug port, results in the following error:

Error: listen EADDRINUSE: address already in use :::9003

Can anyone help with connecting VSCode to xdebug?

Windows 11 says the port is already allocated by wslhost:

PS C:\WINDOWS\system32> Get-Process -Id (Get-NetTCPConnection -LocalPort 9003).OwningProcess

Handles  NPM(K)    PM(K)      WS(K)     CPU(s)     Id  SI ProcessName
-------  ------    -----      -----     ------     --  -- -----------
    285      47     2288       4748       0,05  19480   1 wslhost

Ubuntu tells, its allocated by some docker-proxy:

Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:9003            0.0.0.0:*               LISTEN      17210/docker-proxy
tcp6       0      0 :::9003                 :::*                    LISTEN      17217/docker-proxy

docker-compose-version: docker-compose version 1.25.0

The xdebug.log says:

[Step Debug] INFO: Connecting to configured address/port: host.docker.internal:9003.
[Step Debug] ERR: Time-out connecting to debugging client, waited: 200 ms. Tried: host.docker.internal:9003 (through xdebug.client_host/xdebug.client_port) :-(

For sure as long as nothing is listening.

As to xdebug.client_host I'v tried:

Removing the Expose directive from Dockerfile/docker-compose as in this comment doesn't remove the error neither.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

白云悠悠 2025-02-06 12:26:15

解决了。对于其他面临挑战的人:

WSL -ubuntu的内部 - > docker-containter host.docker.internal 将错误的IP引入。
在WSL-Distribution中,文件 /etc/resolv.conf 是Windows主机的IP。
要获取正确的IP使用此答案:如何获取Linux和OS X上本地计算机的主要IP地址?

可变性

alias docker_compose_local_ip="ifconfig eth0 | sed -En 's/127.0.0.1//;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p'"
export DOCKER_COMPOSE_LOCAL_IP=$(docker_compose_local_ip)

我的解决方案是通过此IP定义 包装容器:

services:
  service-name:
    environment:
      - XDEBUG_CONFIG=client_host=${DOCKER_COMPOSE_LOCAL_IP} ...

Solved it. For others with this challenge:

Inside of wsl-ubuntu -> docker-containter host.docker.internal directs to the wrong ip.
In the wsl-distribution the file /etc/resolv.conf is the ip of the windows host.
To get the correct ip use this answer: How to get the primary IP address of the local machine on Linux and OS X?

My solution is to define an env-variable with this ip:

alias docker_compose_local_ip="ifconfig eth0 | sed -En 's/127.0.0.1//;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p'"
export DOCKER_COMPOSE_LOCAL_IP=$(docker_compose_local_ip)

and configure the container with it:

services:
  service-name:
    environment:
      - XDEBUG_CONFIG=client_host=${DOCKER_COMPOSE_LOCAL_IP} ...
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文