omrikiei / ktunnel

A cli that exposes your local resources to kubernetes
GNU General Public License v3.0
928 stars 71 forks source link

Failed reading from socket, exiting #17

Closed jessebye closed 4 years ago

jessebye commented 4 years ago

When we try to use ktunnel to establish a connection for using xdebug in one of our containers, it works for about 15 seconds before failing with this error:

INFO[2020-04-09 16:32:45] f73e9c2d-ffdb-48dd-aa74-a4f8be552086; new session; connecting to port 9000
ERRO[2020-04-09 16:32:58] f73e9c2d-ffdb-48dd-aa74-a4f8be552086; failed reading from socket, exiting: read tcp 127.0.0.1:55793->127.0.0.1:9000: read: connection reset by peer

The ktunnel command we were using was ktunnel inject -n poor-cannon deployment api 8999:8999

ktunnel version: 1.2.2

omrikiei commented 4 years ago

Hi @jessebye, does the pod in this deployment have multiple containers on it? If you're reverse proxying port 8999, why is the tunnel established to port 9000?

Could you try using the expose subcommand, and configure your pod connect to the ip addr or host of the exposed service?

jessebye commented 4 years ago

@omrikiei I've tried that as well, here's the log result doing that:

ktunnel expose -n poor-cannon xdebug 9000:9000        
INFO[2020-04-14 15:36:58] Exposed service's cluster ip is: 172.20.32.156 
INFO[2020-04-14 15:36:58] waiting for deployment to be ready           
INFO[2020-04-14 15:37:02] Waiting for port forward to finish           
INFO[2020-04-14 15:37:03] Forwarding from 127.0.0.1:28688 -> 28688
Forwarding from [::1]:28688 -> 28688 
INFO[2020-04-14 15:37:03] starting tcp tunnel from source 9000 to target 9000 
INFO[2020-04-14 15:40:34] 76ff906b-af26-43a3-b017-dfe5c0c7ca32; new session; connecting to port 9000 
ERRO[2020-04-14 15:40:37] 76ff906b-af26-43a3-b017-dfe5c0c7ca32; failed reading from socket, exiting: read tcp 127.0.0.1:50306->127.0.0.1:9000: read: connection reset by peer 
omrikiei commented 4 years ago

It seems like the connection was closed by the pod that sent the request to the xdebug service.

Does you development environment listen to DBGP on port 9000?

Do you see anything in the IDE?

jessebye commented 4 years ago

Yes, it is listening to DBGP on port 9000. The IDE shows that a connection is going and receives some traffic from xdebug, but then loses the connection.

omrikiei commented 4 years ago

I assume that when you run xdebug locally and bind it to port 9000 it works right? I want to try an reproduce the issue to debug it, can you recommend on an easy setup of a php app with xdebug, and the IDE you're using?

jessebye commented 4 years ago

@omrikiei this seems like a good one to use: https://github.com/okteto/php-getting-started I am using https://www.jetbrains.com/phpstorm/ for IDE.

omrikiei commented 4 years ago

Hi @jessebye, i've download phpStorm, and followed this tutorial to start debugging with the minimal PHP app from okteto. I managed to sporadically reproduce the issue and I'm looking into this.

omrikiei commented 4 years ago

@jessebye, I released an alpha version - hopefully it should resolve the issue.. could you please try to work with v1.2.3-alpha and let me know the issue persists?

jessebye commented 4 years ago

Hey @omrikiei , that version works! I no longer get disconnected partway through debugging 😄 Thanks for tracking this down and getting it resolved, it will make a big difference for our team!

omrikiei commented 4 years ago

This is awesome to hear, closing this.. thank for your feedback, will release this soon