Can't attach to remote django app within docker
See original GitHub issueI can’t seem to get remote debugging working against a server running within docker. I’ve installed the latest version of ptvsd (4.1.3), vscode, and the python extension. I’ve followed the instructions on the ptvsd readme that details how to launch the debugging client, but I still can’t get it to work.
Environment data
- VS Code version: 1.28.0
- Extension version (available under the Extensions sidebar): 2018.9.0
- OS and version: OSX 10.13.6
- Python version (& distribution if applicable, e.g. Anaconda): 2.7.14 pyenv
- Type of virtual environment used (N/A | venv | virtualenv | conda | …): pyenv virtualenv
- Relevant/affected Python packages and their versions:
On both the local virtualenv and docker app:
ptvsd==4.1.3 Django==1.11.14
Actual behavior
Clicking the debug button in vscode produces a small loading indicator and then does nothing.
Expected behavior
The debugger attaches to the process and enabled debugging session.
Steps to reproduce:
- Start up the django container with ptvsd and ports enabled:
docker-compose run --rm \
--use-aliases \
-p 9292:9292 \
-p 8000:8000 \
app \
python -m ptvsd --port 9292 manage.py runserver app:8000 --nothreading --noreload
This correctly starts the runserver and I can browse the site.
- Configure launch.json to attach to the process:
{
"name": "Django: Attach",
"type": "python",
"request": "attach",
"django": true, // debug template files
"port": 9292,
"pathMappings": [{
"localRoot": "${workspaceFolder}",
"remoteRoot": "/code",
}],
"logToFile": true,
},
- Launch the Django Attach debug configuration
Logs
The only relevant logs that I could find are enabled with the logToFile
directive in the launch configuration which I’ve listed below:
12:40:58 PM, 10/10/2018
Started @ Wed Oct 10 2018 13:40:58 GMT+1100 (AEDT)
From Client:
Content-Length: 313
{"command":"initialize","arguments":{"clientID":"vscode","clientName":"Visual Studio Code","adapterID":"python","pathFormat":"path","linesStartAt1":true,"columnsStartAt1":true,"supportsVariableType":true,"supportsVariablePaging":true,"supportsRunInTerminalRequest":true,"locale":"en-gb"},"type":"request","seq":1}
To Client:
Content-Length: 687
{"seq":1,"type":"response","request_seq":1,"command":"initialize","success":true,"body":{"supportsExceptionInfoRequest":true,"supportsConfigurationDoneRequest":true,"supportsConditionalBreakpoints":true,"supportsSetVariable":true,"supportsExceptionOptions":true,"supportsEvaluateForHovers":true,"supportsModulesRequest":true,"supportsValueFormattingOptions":true,"supportsHitConditionalBreakpoints":true,"supportsSetExpression":true,"supportsLogPoints":true,"supportTerminateDebuggee":true,"supportsCompletionsRequest":true,"exceptionBreakpointFilters":[{"filter":"raised","label":"Raised Exceptions","default":false},{"filter":"uncaught","label":"Uncaught Exceptions","default":true}]}}
From Client:
Content-Length: 362
{"command":"attach","arguments":{"name":"Django: Attach","type":"python","request":"attach","django":true,"port":9292,"pathMappings":[{"localRoot":"/Users/josh/dev/K3","remoteRoot":"/code"}],"logToFile":true,"debugOptions":["Django","RedirectOutput","UnixClient"],"host":"localhost","__sessionId":"05ad6fa4-1331-4978-89e1-acedad6fd8c3"},"type":"request","seq":2}
To Client:
Content-Length: 362
To Client:
{"command":"attach","arguments":{"name":"Django: Attach","type":"python","request":"attach","django":true,"port":9292,"pathMappings":[{"localRoot":"/Users/josh/dev/K3","remoteRoot":"/code"}],"logToFile":true,"debugOptions":["Django","RedirectOutput","UnixClient"],"host":"localhost","__sessionId":"05ad6fa4-1331-4978-89e1-acedad6fd8c3"},"type":"request","seq":2}
To Client:
Content-Length: 313
To Client:
{"command":"initialize","arguments":{"clientID":"vscode","clientName":"Visual Studio Code","adapterID":"python","pathFormat":"path","linesStartAt1":true,"columnsStartAt1":true,"supportsVariableType":true,"supportsVariablePaging":true,"supportsRunInTerminalRequest":true,"locale":"en-gb"},"type":"request","seq":1}
Socket End
check and shutdown
shutdown
Sending Terminated Event
To Client:
Content-Length: 45
onEventTerminated
To Client:
{"seq":0,"type":"event","event":"terminated"}
Shutting down debug session
disposing
From Client:
Content-Length: 79
{"command":"disconnect","arguments":{"restart":false},"type":"request","seq":3}
Socket Error
check and shutdown
Telnet to the server/port from my host machine:
$ telnet localhost 9292
Trying ::1...
Connected to localhost.
Escape character is '^]'.
Connection closed by foreign host.
Output from Console
under the Developer Tools
panel (toggle Developer Tools on under Help
)
INFO no standard startup: not a new window
/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:3294 [samverschueren.final-newline]: Cannot register 'files.insertFinalNewline'. This property is already registered.
E._logMessageInConsole @ /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:3294
E._handleExtensionPointMessage @ /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:3289
r @ /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:3285
e._msg @ /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:3030
e.warn @ /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:3030
u @ /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:3148
t @ /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:3150
o @ /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:3150
(anonymous) @ /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:3150
e._handle @ /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:3031
e.acceptUsers @ /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:3031
E._handleExtensionPoint @ /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:3294
(anonymous) @ /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:3285
g @ /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:160
enter @ /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:164
_run @ /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:165
_completed @ /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:165
/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:3294 [xabikos.JavaScriptSnippets]: Unknown language in `contributes.JavaScriptSnippets.language`. Provided value: vue
E._logMessageInConsole @ /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:3294
E._handleExtensionPointMessage @ /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:3289
r @ /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:3285
e._msg @ /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:3030
e.error @ /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:3030
e.toValidSnippet @ /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:3455
n @ /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:3457
n @ /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:3457
(anonymous) @ /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:3457
e._handle @ /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:3031
e.acceptUsers @ /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:3031
E._handleExtensionPoint @ /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:3294
(anonymous) @ /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:3285
g @ /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:160
enter @ /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:164
_run @ /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:165
_completed @ /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:165
/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:282 [Extension Host] add-new-line-to-files is now active!
/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:282 [Extension Host] vscode-icons is active!
2/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:282 [Extension Host] Git extension API method 'getGitPath' is deprecated.
t.log @ /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:282
t._logExtensionHostMessage @ /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:3160
(anonymous) @ /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:3156
emitTwo @ events.js:126
emit @ events.js:214
emit @ internal/child_process.js:772
_combinedTickCallback @ internal/process/next_tick.js:141
_tickCallback @ internal/process/next_tick.js:180
/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:282 [Extension Host] Python Extension: Get language server folder name, , Return Value: "languageServer.0.1.42"
Issue Analytics
- State:
- Created 5 years ago
- Comments:5
Top GitHub Comments
It logs to the python extension directory. On mobile so can’t link directly but there’s a command in vscode to open the extensions dir. find the python extension folder and it’s debug.log
On Sat, 13 Oct 2018 at 09:17, Gaz Iqbal notifications@github.com wrote:
@jarshwah This has been resolved in the latest version of
PTVSD