- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
Docker 容器中的 Xdebug 无法连接到我系统上的 PhpStorm。
我正在尝试使用 PhpStorm 为 Linux (qubes-os/Fedora 30) 上的 Docker 环境设置 Xdebug。 Xdebug 已启用,我可以访问错误消息。在 PhpStorm 中,我总是使用我给 Xdebug 作为远程主机的相应 IP 更新 DBGp 代理设置。我尝试了很多版本的 Xdebug 设置,但都失败了。
我目前最好的猜测是内部 IP 管理出现问题。这可能是由于 qubes-os ,但我不太相信,因为它是一个普通的 Fedora,而且我以前从未遇到过这样的问题......
我的Xdebug conf
zend_extension=xdebug.so
[Xdebug]
xdebug.idekey=PHPSTORM
xdebug.remote_enable=true
xdebug.remote_port=5902
xdebug.remote_host=host.docker.internal
xdebug.remote_log=/tmp/xdebug-remote.log
(我知道 host.docker.internal
不适用于 Linux。无论如何我都在使用它,通过为此变量设置 IP 来更轻松地进行调试在docker容器的/etc/hosts
文件中)
我的 phpinfo()
xdebug support enabled
Version 2.6.1
IDE Key PHPSTORM
xdebug.remote_enable On On
xdebug.remote_handler dbgp dbgp
xdebug.remote_host host.docker.internal host.docker.internal
xdebug.remote_log /tmp/xdebug-remote.log /tmp/xdebug-remote.log
xdebug.remote_mode req req
xdebug.remote_port 5902 5902
xdebug.remote_timeout 200 200
我的网络日志告诉我,我的请求来自172.18.0.1 - - [31/Oct/2019:09:58:22 +0000] "GET/HTTP/1.1"200 47698 "-""Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML , 像 Gecko) Chrome/78.0.3904.70 Safari/537.36"
我的ifconfig
输出主机
br-8d5002ad7a3a: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 172.18.0.1 netmask 255.255.0.0 broadcast 172.18.255.255
inet6 fe80::42:17ff:feaa:e865 prefixlen 64 scopeid 0x20<link>
ether 02:42:17:aa:e8:65 txqueuelen 0 (Ethernet)
RX packets 5 bytes 513 (513.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 11 bytes 866 (866.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
docker0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 172.17.0.1 netmask 255.255.0.0 broadcast 172.17.255.255
inet6 fe80::42:99ff:fe38:e669 prefixlen 64 scopeid 0x20<link>
ether 02:42:99:38:e6:69 txqueuelen 0 (Ethernet)
RX packets 4055 bytes 233615 (228.1 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 4367 bytes 55073512 (52.5 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.137.0.17 netmask 255.255.255.255 broadcast 10.255.255.255
inet6 fe80::216:3eff:fe5e:6c00 prefixlen 64 scopeid 0x20<link>
ether 00:16:3e:5e:6c:00 txqueuelen 1000 (Ethernet)
RX packets 555370 bytes 785064402 (748.6 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 208464 bytes 13235820 (12.6 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 107 bytes 227427 (222.0 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 107 bytes 227427 (222.0 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
veth0271483: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet6 fe80::183d:fdff:fe2b:f8ce prefixlen 64 scopeid 0x20<link>
ether 1a:3d:fd:2b:f8:ce txqueuelen 0 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 16 bytes 1379 (1.3 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
veth25193ce: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet6 fe80::603c:beff:fe87:6283 prefixlen 64 scopeid 0x20<link>
ether 62:3c:be:87:62:83 txqueuelen 0 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 16 bytes 1379 (1.3 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
vetha36c6d7: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet6 fe80::789d:60ff:fe15:8eb4 prefixlen 64 scopeid 0x20<link>
ether 7a:9d:60:15:8e:b4 txqueuelen 0 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 16 bytes 1379 (1.3 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
vethc039300: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet6 fe80::a0a9:4eff:fe3d:8338 prefixlen 64 scopeid 0x20<link>
ether a2:a9:4e:3d:83:38 txqueuelen 0 (Ethernet)
RX packets 5 bytes 513 (513.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 11 bytes 866 (866.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
vethe777af4: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet6 fe80::c07e:11ff:fe1a:9f6b prefixlen 64 scopeid 0x20<link>
ether c2:7e:11:1a:9f:6b txqueuelen 0 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 16 bytes 1379 (1.3 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
我在 docker 容器上的 ifconfig
输出
eth0 Link encap:Ethernet HWaddr 02:42:AC:12:00:05
inet addr:172.18.0.5 Bcast:172.18.255.255 Mask:255.255.0.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:14 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:1260 (1.2 KiB) TX bytes:0 (0.0 B)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
我的主机上的 netstat -ltn
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:10137 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:6942 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:5902 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:63342 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:20080 0.0.0.0:* LISTEN
tcp6 0 0 ::1:631 :::* LISTEN
tcp6 0 0 :::9000 :::* LISTEN
tcp6 0 0 :::3306 :::* LISTEN
tcp6 0 0 :::80 :::* LISTEN
tcp6 0 0 :::81 :::* LISTEN
tcp6 0 0 :::8082 :::* LISTEN
来自 docker 容器的 netstat -ltn
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 127.0.0.11:34183 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:9001 0.0.0.0:* LISTEN
当使用 xdebug.remote_connect_back=1
我得到
I: Checking remote connect back address.
I: Checking header 'HTTP_X_FORWARDED_FOR'.
I: Checking header 'REMOTE_ADDR'.
I: Remote address found, connecting to 172.18.0.1:5902.
E: Time-out connecting to client (Waited: 200 ms). :-(
Log closed at 2019-10-31 09:32:55
还有当我运行 netstat -nr | grep '^0\.0\.0\.0' | awk '{print $2}'
在 docker 容器中我得到 172.18.0.1
因此我会得出结论,xdebug.remote_host = 172.18.0.1
但是当我使用 docker 添加到容器的 /etc/hosts
的 IP 时(IP 更改为 172.17-18.0.1-4,现在是 172.18.0.4)并查看我得到的 Xdebug 日志
W: Creating socket for 'host.docker.internal:5902', poll success, but error: Operation in progress (29).
E: Could not connect to client. :-(
因此,由于这些 IP 有点不确定,我只是简单地尝试了我在途中遇到的每个 IP 作为 docker 容器的 xdebug.remot_host
。我是来自 xdebug 的上述失败日志之一
另外telnet
和ping
的结果:
telnet 172.18.0.1 5902:
telnet: can't connect to remote host (172.18.0.1): Operation timed out
bash-4.4# telnet 172.18.0.4
telnet: can't connect to remote host (172.18.0.4): Connection refused
bash-4.4# ping 172.18.0.1:
5 packets transmitted, 0 packets received, 100% packet loss
bash-4.4# ping 172.18.0.4
PING 172.18.0.4 (172.18.0.4): 56 data bytes
5 packets transmitted, 5 packets received, 0% packet loss
结论:我迷路了。我基本上尝试了所有可能的 IP 地址。请帮助我了解我需要做什么才能调试我的 PHP 代码。谢谢!
最佳答案
如果您在本地机器上并且有一个 docker 容器,那么设置 xdebug.remote_host=host.docker.internal
并添加 host.docker.internal
就足够了到/etc/hosts。
我在条目 sh 脚本中执行此操作:netstat -nr | grep '^0\.0\.0\.0' | awk '{print $2"host.docker.internal"}' >>/etc/hosts
如何检查数据是否发送:
xdebug.remote_log=/var/log/xdebug_remote_log.log
nc -l 5902
或 nc -l 0.0.0.0 5902
上的端口。通过 telnet 从 docker telnet host.docker.internal 5902
发送文本并输入一些内容。您应该在主机上的 nc
中看到它如果您的 docker 在远程主机上,那么您必须允许 ssh GatewayPorts yes
监听 0.0.0.0:5904 或将流量转发到 127.0.0.0:5905。看here
socat TCP-LISTEN:5904,fork TCP:127.0.0.1:5905
ssh -R 5905:localhost:5904
您可以使用nc
和telnet
检查连接。
关于linux - docker 容器中的 Xdebug 无法连接到 Qubes OS 上的 PhpStorm,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58641781/
我通过 spring ioc 编写了一些 Rest 应用程序。但我无法解决这个问题。这是我的异常(exception): org.springframework.beans.factory.BeanC
我对 TestNG、Spring 框架等完全陌生,我正在尝试使用注释 @Value通过 @Configuration 访问配置文件注释。 我在这里想要实现的目标是让控制台从配置文件中写出“hi”,通过
为此工作了几个小时。我完全被难住了。 这是 CS113 的实验室。 如果用户在程序(二进制计算器)结束时选择继续,我们需要使用 goto 语句来到达程序的顶部。 但是,我们还需要释放所有分配的内存。
我正在尝试使用 ffmpeg 库构建一个小的 C 程序。但是我什至无法使用 avformat_open_input() 打开音频文件设置检查错误代码的函数后,我得到以下输出: Error code:
使用 Spring Initializer 创建一个简单的 Spring boot。我只在可用选项下选择 DevTools。 创建项目后,无需对其进行任何更改,即可正常运行程序。 现在,当我尝试在项目
所以我只是在 Mac OS X 中通过 brew 安装了 qt。但是它无法链接它。当我尝试运行 brew link qt 或 brew link --overwrite qt 我得到以下信息: ton
我在提交和 pull 时遇到了问题:在提交的 IDE 中,我看到: warning not all local changes may be shown due to an error: unable
我跑 man gcc | grep "-L" 我明白了 Usage: grep [OPTION]... PATTERN [FILE]... Try `grep --help' for more inf
我有一段代码,旨在接收任何 URL 并将其从网络上撕下来。到目前为止,它运行良好,直到有人给了它这个 URL: http://www.aspensurgical.com/static/images/a
在过去的 5 个小时里,我一直在尝试在我的服务器上设置 WireGuard,但在完成所有设置后,我无法 ping IP 或解析域。 下面是服务器配置 [Interface] Address = 10.
我正在尝试在 GitLab 中 fork 我的一个私有(private)项目,但是当我按下 fork 按钮时,我会收到以下信息: No available namespaces to fork the
我这里遇到了一些问题。我是 node.js 和 Rest API 的新手,但我正在尝试自学。我制作了 REST API,使用 MongoDB 与我的数据库进行通信,我使用 Postman 来测试我的路
下面的代码在控制台中给出以下消息: Uncaught DOMException: Failed to execute 'appendChild' on 'Node': The new child el
我正在尝试调用一个新端点来显示数据,我意识到在上一组有效的数据中,它在数据周围用一对额外的“[]”括号进行控制台,我认为这就是问题是,而新端点不会以我使用数据的方式产生它! 这是 NgFor 失败的原
我正在尝试将我的 Symfony2 应用程序部署到我的 Azure Web 应用程序,但遇到了一些麻烦。 推送到远程时,我在终端中收到以下消息 remote: Updating branch 'mas
Minikube已启动并正在运行,没有任何错误,但是我无法 curl IP。我在这里遵循:https://docs.traefik.io/user-guide/kubernetes/,似乎没有提到关闭
每当我尝试docker组成任何项目时,都会出现以下错误。 我尝试过有和没有sudo 我在这台机器上只有这个问题。我可以在Mac和Amazon WorkSpace上运行相同的容器。 (myslabs)
我正在尝试 pip install stanza 并收到此消息: ERROR: No matching distribution found for torch>=1.3.0 (from stanza
DNS 解析看起来不错,但我无法 ping 我的服务。可能是什么原因? 来自集群中的另一个 Pod: $ ping backend PING backend.default.svc.cluster.l
我正在使用Hibernate 4 + Spring MVC 4当我开始 Apache Tomcat Server 8我收到此错误: Error creating bean with name 'wel
我是一名优秀的程序员,十分优秀!