Port-forward connections are fragile for some protocols

Our clusters are running k8s v1.24. I have experimented with using port-forward for some diagnostic and testing purposes, and simple use cases work fine. For instance, our services are mostly Java REST services listening on port 8080. Forwarding 8080 to my desktop and testing the main endpoint works fine.

However, I’ve also configured the services with the Java “Xdebug” parameters, to facilitate a remote debug connection, and when I forward that port, it sort of works, but the connection consistently fails with “broken pipe” errors after a short time. I would guess that this protocol is much more “chatty” than our simple REST endpoints. This happens either while I also have an additional forwarded port for the REST endpoint, or not.

I’ve read about the hack of putting the port-forward in an infinite loop, but I think it’s likely that won’t help here. The instant I get the broken pipe error, the debugger loses the connection.

I’m seeing some statements about port-forward not being scalable, so I guess there’s no way to “fix” this. Is there a different strategy that might make setting up a remote debugger connection more practical?