-
-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PyCharm debugger waiting for process connection #60
Comments
Hi @ahlae - could you reproduce this issue with verbose mode in ktunnel so that debug logs are also seen? |
Hi @omrikiei, thank you for your fast response. <3 Yes, 'local' remote debugging works. I launch a docker container running the app, install the pydevd_pycharm package and the connection back to PyCharm works without issues. The PyCharm Debug console shows me: Starting debug server at port 5,678 The command I use to install the package in the local container as well as in the cluster is: pip install pydevd-pycharm~=211.7628.24 This pydevd version is what I'm told to install by PyCharm in the Run/Debug configuration. I'm using the following PyCharm version: PyCharm 2021.1.3 (Professional Edition) The app image I'm trying to debug on kubernetes is based on alpine:latest. When I use ktunnel with verbose mode on it outputs: ktunnel inject deployment -n ... ... 5678 --verbose When starting ktunnel it sits waiting at DEBU[2021-07-17 11:07:54.024] attempting to receive from stream The stuff beginning with "INFO[2021-07-17 11:10:26.378] new connection" only shows up when interrupting the app with CTRL-C. I thought it might be a problem with Python3 in the container compiled by a different GCC compiler Python 3.9.5 (default, May 12 2021, 20:44:22) and on my laptop Python 3.9.5 (default, May 24 2021, 12:50:35) But the local container works. The connection to the cluster is routed through Wireguard VPN since it is a private cluster. Sending TLS traffic through a VPN connection sometimes create issues with packet size and fragmentation. To remediate this the MTU is set to 1380. kubectl proxy, ksync, skaffold and telepresence are working perfectly fine. Thanks again for your time! :) |
Hi @ahlae - one more question: |
I tried different options. Since I'm setting this debugging workflow up for the first time I put the settrace after importing the pydevd module during application init. Then I tried different positions in functions or 'main'. All with the same result as described above. |
Well, it's very likely that the app is being initialized before the tunnel is established.
|
Hi @omrikiei - I can explain my workflow for setting up the debugging session because I think the tunnel is readily established when starting the app: Because I wanted to test things out before building it into the real app I'm using the PyCharm python project example which has only one file called main.py:
I follow the subsequent steps:
I think your recommendation to insert a 30 seconds delay is already respected while following these steps. As a last resort I'm going to try your first recommendation and setup the debugger in the real app with a web endpoint. |
Sadly there seems to be no chance for me to get this running. I tried a web endpoint in the application which produces the same results as described above. I even installed an Ubuntu Desktop into the cluster network (to be able to use PyCharm) to rule out an issue with the VPN connection but without success. Btw I'm running this on EKS with Kubernetes 1.19. |
Hi @ahlae, have you tried using the |
Hi @omrikiei - I tried what you proposed, expose and suspend=False. Always the same result: Starting debug server at port 5,678 I will look into finding some time and setting up a go debugging session. I really want this to get working. Your tool is super useful. :) |
Hello @ahlae, wanted to know if you've made any progress with a debugging session, and if this issue is still relevant |
Hi @omrikiei, yes, this is still an issue. Atm I'm working on several issues that popped up and I didn't had time to resolve it. For now we kept developing and debugging locally. If you want to close the issue we can do this and I'll write you a PM when I've finished. |
@ahlae hi, is this issue still relevant? |
@omrikiei Hi, yes, but I'm too busy to solve it right now. I'm going to close the issue and reopen it when continuing on it. |
For the record, I'm experiencing the same issue with PyCharm 2021.2.3 (i.e., Apart from trying to tunnel the debugger, I also tried tunneling a locally running flask hello world site into the deployment, and that worked flawlessly. So apparently, the problem could be with pycharm or the EKS cluster. |
I also tested this with pycharm Build #PY-213.5744.248 and the connection to the debugger starting only when pressing CTRL+C in the python console. |
FYI, I'm facing the same issue. |
@cedricspaceiq I'm facing the issue on PC. I don't think this is connected to an Apple M1. |
Same issue for me, can't even get the example to run. |
I'm seeing this as well. |
I'm having a similar issue, looking at the verbose output, and testing with How I have replicated:
TLDR; My testing is on AWS EKS with k8s v1.22. I've also tried the PyCharm example using |
Further to the above, the logs that come through to the For example, on the PC I ran: And then on a pod I ran:
I then sent a single character (and newline) from the pod:
So the issue is the same, but it does look like there's an issue in |
I think this fixes the issue. I'll do more testing and put in a PR once confirmed: diff --git a/pkg/server/server.go b/pkg/server/server.go
index 266bc49..27495e9 100644
--- a/pkg/server/server.go
+++ b/pkg/server/server.go
@@ -125,6 +125,8 @@ func ReceiveData(conf *Config, stream pb.Tunnel_InitTunnelServer) {
func readConn(ctx context.Context, conf *Config, session *common.Session, sessions chan<- *common.Session) {
conf.log.WithField("session", session.Id.String()).Info("new connection")
+ conf.log.Debug("starting session with sessions <- session")
+ sessions <- session
for {
|
@sillyfrog thanks for opening a PR. |
After starting the PyCharm debugger with IDE host name 0.0.0.0, port 5678 and correct path mappings, then setting up the tunnel and starting the remote application with
import pydevd_pycharm
pydevd_pycharm.settrace('localhost', port=5678, stdoutToServer=True, stderrToServer=True)
in the source code (using pip install pydevd-pycharm~=211.7628.24 as the PyCharm run/debug configuration tells me) the PyCharm debugger doesn't start the debugging process properly. It keeps showing
Waiting for process connection...
When stopping the remote application with CTRL-C the stdout/stderr is nonetheless transmitted to PyCharm and appears in the debug console:
Traceback (most recent call last):
File "/opt/app-root/./main.py", line 9, in
pydevd_pycharm.settrace('127.0.0.1', port=5678, stdoutToServer=True, stderrToServer=True, suspend=False)
File "/home/precisionlims/.local/lib/python3.9/site-packages/pydevd.py", line 1689, in settrace
_locked_settrace()
Waiting for process connection...
Server stopped.
The tunnel is logging:
INFO[2021-07-16 11:08:45.939] new connection port=5678 session=fddfa455-d934-4fd2-8588-aed7d5e48631
INFO[2021-07-16 11:08:45.970] closed session session=fddfa455-d934-4fd2-8588-aed7d5e48631
Like if the connection was opened and closed at the same time.
So there is a successful connection attempt made. What might be the issue here?
The text was updated successfully, but these errors were encountered: