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

VS code remote debug connect fail. #133

Closed
DonJayamanne opened this Issue Nov 13, 2017 · 24 comments

Comments

Projects
None yet
7 participants
@DonJayamanne
Copy link

DonJayamanne commented Nov 13, 2017

From @AwayQuEM on June 20, 2017 3:29

Environment data

VS Code version: 1.13.1 on Mac
Python Extension version: 0.6.5 on mac
Python Version: 3.5.2
OS and version: OS X 10.12.5
ptvsd version:3.0.0 on Mac

Actual behavior

I still got 'Debug adapter process has terminated unexpectedly' with ptvsd==3.0.0

Steps to reproduce:

  • run test.py
  • then run debug in vscode

Settings

Your launch.json (if dealing with debugger issues):

{
    "version": "0.2.0",
    "configurations": [
         {
            "name": "Attach (Remote Debug)",
            "type": "python",
            "request": "attach",
            "localRoot": "${workspaceRoot}",
            "secret": "secet",
            "port": 8010,
            "host": "localhost",
            "remoteRoot": "${workspaceRoot}"
        }
    ]
}

Your settings.json:

{
    "python.pythonPath": "/Users/away/wanjia/test_remote_debug/venv/bin/python",
    "python.autoComplete.extraPaths": [
        "/Users/away/wanjia/test_remote_debug/venv/lib/python3.5/site-packages"
    ],
    "python.linting.enabled": false
}

Logs

Output from Console window (Help->Developer Tools menu)


messageService.ts:125 Debug adapter process has terminated unexpectedly
e.doShow @ messageService.ts:125
e.show @ messageService.ts:104
g.onServerExit @ rawDebugSession.ts:517
(anonymous) @ rawDebugSession.ts:431
emitTwo @ events.js:111
emit @ events.js:191
__dirname.ChildProcess._handle.onexit @ internal/child_process.js:215

Code

import ptvsd

address = ('0.0.0.0', 8010)
ptvsd.enable_attach('secret', address)
ptvsd.wait_for_attach()
print('connected')

Copied from original issue: DonJayamanne#1039

@DonJayamanne

This comment has been minimized.

Copy link

DonJayamanne commented Nov 13, 2017

From @papaiatis on June 27, 2017 10:49

Same problem here.

@DonJayamanne

This comment has been minimized.

Copy link

DonJayamanne commented Nov 13, 2017

From @joenot443 on June 28, 2017 19:1

Have had the same issue for several weeks now, would really like to see a fix.

@DonJayamanne

This comment has been minimized.

Copy link

DonJayamanne commented Nov 13, 2017

Please could each of you confirm that you have PTVSD version 3.0.0 installed and not the latest version of PTVSD.

@DonJayamanne

This comment has been minimized.

Copy link

DonJayamanne commented Nov 13, 2017

From @papaiatis on June 29, 2017 11:57

I had 3.1.0 installed. Downgraded, but did not help. Still getting the "Debug adapter process has terminated unexpectedly" message.
Note that I have a REST API to run with gunicorn, that I'd like to debug with this.

@DonJayamanne

This comment has been minimized.

Copy link

DonJayamanne commented Nov 13, 2017

From @asierralozano on July 4, 2017 4:55

Same issue here. Using PTVSD 3.0.0 too

@DonJayamanne

This comment has been minimized.

Copy link

DonJayamanne commented Nov 13, 2017

From @commagere on July 25, 2017 2:49

I'm seeing this exact issue as well - even with the "hello_world" test app.
This is using the following versions of each component:

VS Code version: 1.14.2
Python Extension version: 0.6.9
Python Version: 2.7.10
OS and version: OS X 10.12.6
ptvsd version:3.0.0

@DonJayamanne

This comment has been minimized.

Copy link

DonJayamanne commented Nov 13, 2017

From @marcosfede on August 24, 2017 3:44

Same here, using ptvsd 3.0.0. Devtools shows TypeError: Cannot read property 'Threads' of undefined

@DonJayamanne

This comment has been minimized.

Copy link

DonJayamanne commented Nov 13, 2017

From @Petezah on August 29, 2017 19:46

Same. ptvsd 3.0.0 also.

@sgtoj

This comment has been minimized.

Copy link

sgtoj commented Dec 11, 2017

I had the same issue. I resolved it by installing PTVSD 3.0.0 on the remote environment (i.e. docker container). PTVSD on the local enviroment does not affect it. In fact, I uninstalled PTVSD from machine to confirm.

I do feel like the latest version should be supported, though.

@dan-kez

This comment has been minimized.

Copy link

dan-kez commented Dec 23, 2017

I have the same error however I am using PTVSD 3.2.1.

@DonJayamanne

This comment has been minimized.

Copy link

DonJayamanne commented Dec 24, 2017

@dmk255 please use 3.0.0, anything later than that isn't currently supported.

@dan-kez

This comment has been minimized.

Copy link

dan-kez commented Dec 24, 2017

@DonJayamanne I didn't realize it was important to have that exact version. Is there a good place in the Docs to add this? I'm happy to write it up.

@brettcannon

This comment has been minimized.

Copy link
Member

brettcannon commented Jan 2, 2018

@dmk255 It's already documented: https://code.visualstudio.com/docs/python/debugging#_remote-debugging (see step 1).

@DonJayamanne

This comment has been minimized.

Copy link

DonJayamanne commented Jan 2, 2018

@brettcannon the problem is the documentation indicates that later versions are supported, when this isn't the case. I've created an issue to ensure this is fixed #514.

@DonJayamanne

This comment has been minimized.

Copy link

DonJayamanne commented Jan 4, 2018

@AwayQuEM @papaiatis @joenot443 @asierralozano @commagere @Petezah
Hi everyone, I'd like to get to the bottom of this issue. Unfortunately I haven't been able to replicate this issue at my end. Would it be possible for one of you to provide the following, that would help me replicate the issue:

  • Sample code
  • Environment information (OS, Python version, path to code on your environment)
  • Instructions to replicate
@marcosfede

This comment has been minimized.

Copy link

marcosfede commented Jan 6, 2018

@DonJayamanne I just tried to reproduce the issue.

local Environment:

  • OS: Arch linux
  • python version 3.6.4
  • path to code: /usr/bin/code

remote environment:

  • python 3.6.4 running inside a docker container

The only way I've managed to get the remote debugger connected is by using the following configs:

manage.py

#!/usr/bin/env python
import os
import sys

if __name__ == '__main__':
    os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings.local')

    try:
        from django.core.management import execute_from_command_line
    except ImportError:
        # The above import may fail for some other reason. Ensure that the
        # issue is really that Django is missing to avoid masking other
        # exceptions on Python 2.
        try:
            import django  # noqa
        except ImportError:
            raise ImportError(
                "Couldn't import Django. Are you sure it's installed and "
                "available on your PYTHONPATH environment variable? Did you "
                "forget to activate a virtual environment?"
            )
        raise

    # This allows easy placement of apps within the interior
    # backend directory.
    current_path = os.path.dirname(os.path.abspath(__file__))
    sys.path.append(os.path.join(current_path, 'backend'))

    import ptvsd
    address = ('0.0.0.0', 9000)
    ptvsd.enable_attach('secret', address)
    # print('waiting for attach...')
    # ptvsd.wait_for_attach()

    execute_from_command_line(sys.argv)

startup command:
python manage.py runserver_plus --noreload --nothreading 0.0.0.0:8000
(noreload is important here otherwise it throws an address already in use error)

launch.json configs

{
            "name": "Attach (Remote Debug)",
            "type": "python",
            "request": "attach",
            "localRoot": "${workspaceRoot}",
            "remoteRoot": "${workspaceRoot}",
            "port": 9000,
            "secret": "secret",
            "host": "localhost"
        }

However:

  • I can not see on which line is being paused on
  • Code does not take me to the line once I hit a breakpoint
  • only works with ptvsd version 3.0.0, tried with 3.2.1 but it throws the Debug adapter process has terminated unexpectedly

let me know if you need some more information
Thanks

@DonJayamanne

This comment has been minimized.

Copy link

DonJayamanne commented Jan 11, 2018

@marcosfede

only works with ptvsd version 3.0.0, tried with 3.2.1 but it throws the Debug adapter process has terminated unexpectedly

So, it works for you with the version 3.0.0. Thanks.

I'm looking for a sample code (repo) that I could use to replicate this issue using PTVSD version 3.0.0.

@Petezah

This comment has been minimized.

Copy link

Petezah commented Jan 11, 2018

Okay, finally found a minute to try this. I can still currently repro this with this command line python script (with version 3.0.0, launched with python3 on a Mac):

import ptvsd

if __name__ == "__main__":
    ptvsd.enable_attach("my_secret")
    ptvsd.wait_for_attach()
    print("hello world")

with launch.json config:

{
  "name": "Python: Attach",
  "type": "python",
  "request": "attach",
  "localRoot": "${workspaceFolder}",
  "remoteRoot": "${workspaceFolder}",
  "port": 3000,
  "secret": "my_secret",
  "host": "localhost"
}

I get the following error:

There was an error in starting the debug server. Error = {"code":"ECONNREFUSED","errno":"ECONNREFUSED","syscall":"connect","address":"127.0.0.1","port":3000}
@DonJayamanne

This comment has been minimized.

Copy link

DonJayamanne commented Jan 18, 2018

@Petezah
Please could you provide the following info:

Environment information (OS, Python version, path to code on your environment)

Looks like you're the only one experiencing this issue with PTVSD 3.0.0

@Petezah

This comment has been minimized.

Copy link

Petezah commented Jan 19, 2018

Sure thing.
OS: Mac OS X version 10.13.2 ("High Sierra")
Python: 3.6.3
Code is in: ~/Source/Repos/projectFolder
Python3 is installed in: /usr/local/bin/

@DonJayamanne

This comment has been minimized.

Copy link

DonJayamanne commented Jan 22, 2018

@Petezah please could you try changing the port to something else and trying once again. Thanks

@Petezah

This comment has been minimized.

Copy link

Petezah commented Jan 22, 2018

Arrrgh. Ok, I see why this wasn't working now. DEFAULT_PORT is actually 5678, not 3000. The adapter was trying to attach to 3000 (just from the boilerplate attach.json stuff). Setting the port manually works, even with port 3000. Did this change recently? I swear I was just using the default params before, and it was working for me.

@DonJayamanne

This comment has been minimized.

Copy link

DonJayamanne commented Jan 22, 2018

@Petezah Oh yes, I missed that too, you weren't providing a port number. Thanks.
Ok, looks this issue is scoped just to linux OS.

@DonJayamanne

This comment has been minimized.

Copy link

DonJayamanne commented Jan 22, 2018

This seems to be resolved for most people either by providing the port number or using PTVSD 3.0.0.
Others haven't come back with further information, hence I'm closing this issue.

@lock lock bot locked as resolved and limited conversation to collaborators Jul 12, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.