Recently when I try to debug a python application using the Toradex extension for Visual studio, I get an error “Client not authenticated”.
The application still runs on the board but it seems like I can’t attached the debugger.
Looking at the extension logs, I get the following:
2024-08-06 17:44:50.138 [error] TypeError: Cannot read properties of undefined (reading 'split')
at DeviceConnect._isValidIP (/home/torizon/.vscode/extensions/toradex.apollox-vscode-2.5.2-linux-x64/out/Commands/DeviceConnect.js:186:27)
at /home/torizon/.vscode/extensions/toradex.apollox-vscode-2.5.2-linux-x64/out/Commands/DeviceConnect.js:126:23
at f.h (/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:154:204392) apollox.NetworkDeviceAdd {"value":"Toradex.apollox-vscode","_lower":"toradex.apollox-vscode"}
The board IP was added manually, set as default. I can access everything as you’d normally do: running containers, attach shell to container etc. I just can’t seem to debug the application.
Debug ports are included in the docker compose file (debug config):
Hi, I’m the Toradex AI Assistant. I’m in early beta, and I would appreciate your feedback.
The Toradex Support team will follow up with you shortly!
Did you like my answer?
Hello,
The error message and the logs you’ve provided suggest there might be an issue with how the Visual Studio Code extension for Toradex (presumably for Torizon) is handling the device connection, particularly in parsing the IP address or managing authentication for the debug client. The TypeError pointing to ‘split’ being called on an undefined object indicates that some expected data is not being correctly retrieved or processed.
Here are a few steps you can take to troubleshoot and potentially resolve the issue:
Verify IP Address Configuration: Ensure that the IP address of your board is correctly configured in the extension settings. It might be beneficial to double-check if the IP address has changed or if there are any network issues preventing proper communication.
Extension and Dependencies Update: Make sure that your Visual Studio Code, the Toradex extension, and any related dependencies are up to date. An outdated extension or conflict between versions could lead to unexpected errors.
Check Authentication Settings: The “Client not authenticated” error suggests there might be an issue with how the debugger is authenticating to the device. Verify if there are any specific authentication settings or tokens that need to be refreshed or correctly set up within the extension or the development environment.
Review Docker Compose Configuration: Although the ports are correctly exposed in your Docker compose file, ensure that there are no network restrictions or firewall settings on your development machine or the board that might be blocking these ports.
Debugging Service Configuration: Ensure that the debugging service (e.g., for Python, this could be related to ptvsd or another debugger) is correctly set up and running on the specified ports within your container. It might be helpful to manually test the connection to these ports from your development machine to verify they are accessible.
Logs and Error Messages: Review any additional logs or error messages from both the development environment and the board. There might be more detailed information available that can help pinpoint the exact cause of the authentication issue.
Restart Services and Devices: Sometimes, simply restarting Visual Studio Code, the extension, and the board can resolve transient issues or refresh connections that have become unstable.
If after following these steps the issue persists, it might indicate a deeper problem with the extension or the development setup that requires a more detailed investigation. Since direct support channels are not within the scope of this assistance, exploring community forums or official documentation for similar issues might provide further insights.
Best regards,
Toradex AI Assistant
Please, also check if these links can help you solve your problem:
Yes, I have removed the board and added it again, still not working.
Also tried updating VSCode and the Torizon extension:
VSCode: V 1.92.0
Torizon Extension: V 2.5.2
I also tried going back to an old commit just to discard any possible new changes there and still not working.
When I try to start the debug session I can see some of the expected subprocesses starting but after a 2 or 3 seconds they disappear and I get that message from the previous post.
I’ve also noticed this happening, not sure if related:
2024-08-07 13:45:52.926 [error] Error: Unclosed root tag
Line: 5
Column: 0
Char:
at error (/home/torizon/.vscode/extensions/toradex.apollox-vscode-2.5.2-linux-x64/node_modules/sax/lib/sax.js:651:10)
at strictFail (/home/torizon/.vscode/extensions/toradex.apollox-vscode-2.5.2-linux-x64/node_modules/sax/lib/sax.js:677:7)
at end (/home/torizon/.vscode/extensions/toradex.apollox-vscode-2.5.2-linux-x64/node_modules/sax/lib/sax.js:658:47)
at SAXParser.write (/home/torizon/.vscode/extensions/toradex.apollox-vscode-2.5.2-linux-x64/node_modules/sax/lib/sax.js:975:14)
at SAXParser.close (/home/torizon/.vscode/extensions/toradex.apollox-vscode-2.5.2-linux-x64/node_modules/sax/lib/sax.js:157:38)
at Parser.exports.Parser.Parser.parseString (/home/torizon/.vscode/extensions/toradex.apollox-vscode-2.5.2-linux-x64/node_modules/xml2js/lib/parser.js:323:42)
at Parser.parseString (/home/torizon/.vscode/extensions/toradex.apollox-vscode-2.5.2-linux-x64/node_modules/xml2js/lib/parser.js:5:59)
at /home/torizon/.vscode/extensions/toradex.apollox-vscode-2.5.2-linux-x64/node_modules/xml2js/lib/parser.js:338:24
at new Promise (<anonymous>)
at Parser.exports.Parser.Parser.parseStringPromise (/home/torizon/.vscode/extensions/toradex.apollox-vscode-2.5.2-linux-x64/node_modules/xml2js/lib/parser.js:336:14)
at Parser.parseStringPromise (/home/torizon/.vscode/extensions/toradex.apollox-vscode-2.5.2-linux-x64/node_modules/xml2js/lib/parser.js:5:59)
at Object.exports.parseStringPromise (/home/torizon/.vscode/extensions/toradex.apollox-vscode-2.5.2-linux-x64/node_modules/xml2js/lib/parser.js:378:19)
at NmapScan.run (/home/torizon/.vscode/extensions/toradex.apollox-vscode-2.5.2-linux-x64/node_modules/network-mapper/lib/scans/nmap-scan/NmapScan.js:19:43)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
Just to clarify these logs you’re sharing where are they from? They do not appear to be from the VSCode terminal output. Could you share the output you’re getting on the VSCode terminal when running the debug task. This may provide more information.
I also tried going back to an old commit just to discard any possible new changes there and still not working.
So did this work fine for you in the past? Was it only recently this issue occurred? If yes, then can you recall if anything about your setup changed recently.
Seems like this is related to using a flask version greater than 1.1.3. We’re going back to using an old version of flask for now and at some point I might try to investigate the issue.
Seems like this is related to using a flask version greater than 1.1.3. We’re going back to using an old version of flask for now and at some point I might try to investigate the issue.
Interesting, that is good to know for future reference. Out of curiosity, how did you determine that the Flask version was the issue? Did you just rollback to an older version of Flask and the debug process worked again?
Yes, rolling back everything until we could isolate the issue to just the flask dependency. It would be interesting to know if someone on Toradex side can reproduce the problem.
The version of Flask here is “3.0.3”. With this the debug process worked fine and I had no issues. Maybe this is too simple and I have to use Flask in a certain way? Not sure.
So your theory might still be correct that there’s some weird issue with debugpy and Flask. Though I didn’t find an exact match with what you’re obeserving.