cmcpasserby / MayaCharm

Maya integration for PyCharm.
MIT License
177 stars 44 forks source link

MayaCharm connect but breakpoints are not caught by the debugger. #57

Closed chadlichty closed 3 years ago

chadlichty commented 3 years ago

PyCharm 2020.3.5 (Professional Edition) Build #PY-203.7717.81, built on March 25, 2021

MayaCharm version 3.2.2

Maya 2020.3.1-16.0PFIX

I was having an issue with the debugger failing to connect. With this error: Connection to Python debugger failed Socket operation on nonsocket: configureBlocking

I found this post and followed its suggestion. Disable "PyQt compatible" checkbox in the Settings under Build, Execution, Deployment --> Python Debugger. Then debug again the code and it should works.

I do not get the error anymore but the debugger is still not catching the breakpoints.

I have a second workstation that unfortunately is offsite at my office. This workstation works as expected. Same versions of PyCharm, MayaCharm, and Maya. So I know it will work I just can't figure out what is preventing it from working on my laptop.

When connected to maya I can run print("hello") in the script editor and the output is printed in the debugger console. It just won't catch breakpoints.

On my other machine, I do not have the PyQt compatible checkbox unchecked.

I tried setting that to PySide2 and the debugger connects without an error but still does not catch breakpoints.

Any suggestions? It's so painful to code and test in maya over a remote desktop connection with slow internet.

Oh, and I was having this issue with the older plugin versions. So I'm pretty sure it is something with my setup.

Thanks,

Chad.

cmcpasserby commented 3 years ago

do things work when just running some code in maya using the run configuration pycharm?

chadlichty commented 3 years ago

I can execute code and execute a file using the run configuration. Still no breakpoints are caught.

cmcpasserby commented 3 years ago

can you show me what is in the debugging console when you try to attach, do you ever get the "Successfully attached to Maya" message in there, and what does the command at the top of it look like

chadlichty commented 3 years ago

D:\VasgApps\maya\2020\maya2020_pfix_16_0\bin\mayapy.exe C:\Users\clichty\AppData\Local\JetBrains\PyCharm2020.3\MayaCharm\vasg_infrastructure.4a9b6bfa\python\attach_pydevd.py --port 63957 --pid 26464 --mcPort 4437 --pydevPath "C:\Program Files\JetBrains\PyCharm 2020.3.3\plugins\python\helpers\pydev" Connected to pydev debugger (build 203.7717.81) Successfully attached to Maya

cmcpasserby commented 3 years ago

seems pretty odd in your case, port 4437 does point to the correct maya instance, and you have nothing that is blocking communications with port 63957.

how are you running the thing you want to debug?

chadlichty commented 3 years ago

image I have four different maya's that is why the port number is different. I will have to double check with IT if port 63957 is blocked.

I'm usually debugging QT UIs. So I launch them from the script editor and will have a breakpoint set in one the python file.

chadlichty commented 3 years ago

My other machine also has the four different maya's. So I know that isn't the issue. I'm hoping IT is blocking the port. This is my laptops and I'm working from home like most everyone these days. So I'm over a VPN and that port may be blocked.

cmcpasserby commented 3 years ago

yeah good chance its that, i did no testing via vpn, but it is trying to access ports on the local host

chadlichty commented 3 years ago

It could also be just extra security they put on laptops. Do you know the a range of port numbers mayaCharm uses for debugging? I'm getting different ports everytime I try to run it. The pyCharm built-in server debugger is set to the default value of 63342.

cmcpasserby commented 3 years ago

port range will be dependent on your operating system, since i am just relying on the OS to give me a port from the ephemeral port range. On windows you should be able to check than range with. netsh int ipv4 show dynamicport tcp

On macOS you can get the range with. sysctl net.inet.ip.portrange.first net.inet.ip.portrange.last

if I am understanding what the JVM is doing correctly that is.

For communication on the Maya command port, its pretty primitive and works in the 4434 to 4534 range, and sequentially assigns them to Maya installs as you add them. It does no checking to ensure its free so will just give you the connection refused message if the connection fails for any reason.

cmcpasserby commented 3 years ago

I get the feeling it could be something else like pathing too. I noticed if I source the script in the Maya script editor breakpoints will not be hit, but if I import the module and execute something on it from either the script editor or run config it will work, or what in normally do is use a run config with execute file mode and just have a if __name__ == "__main__": guard in my script so it can be imported normally or executed.

chadlichty commented 3 years ago

Yeah that is how I am operating. Here is an example of how I'm launching to debug vasgImport is just a custom python importer that handles all our version control for different projects, testing, etc.

import vasgImport vasgHud = vasgImport.importPackage("vasgHud", version=0.5, reloadModule=True) hudUI = vasgHud.VASGHud() hudUI.show()

chadlichty commented 3 years ago

I'm working with our IT department and we have not found any issues with the firewall. After setting up a debug session by attaching it to maya. IT was able to telnet and connect to the port that was created by pyCharm attaching to maya. IT is interested to see if that tells you anything. As far as pathing are you suggesting that I have breaks in file x but file y is actually running in Maya? I certainly have done that in the past but am pretty certain that isn't the current issue. I can verify the paths are correct if that is what you are referring to.

chadlichty commented 3 years ago

Also Thanks for the 2021 update!!!

chadlichty commented 3 years ago

Chris I might have found something. The debugger console appears to be connected: D:\VasgApps\maya\2018\maya2018_x64_sie-4.2\bin\mayapy.exe C:\Users\clichty\AppData\Local\JetBrains\PyCharm2021.1\MayaCharm\vasg_infrastructure.4a9b6bfa\python\attach_pydevd.py --port 63215 --pid 20288 --mcPort 4434 --pydevPath "C:\Program Files\JetBrains\PyCharm 2020.3.3\plugins\python\helpers\pydev" Connected to pydev debugger (build 211.6693.115) Successfully attached to Maya However in the eventlog I have an error. 3:15 PM Connection to Python debugger failed: Socket operation on nonsocket: configureBlocking

chadlichty commented 3 years ago

IT was able to telnet to 63215 so it appears to be open

chadlichty commented 3 years ago

This seems to be working good. I have intermittent issues where I have to clear out all my break points and create new ones then it works. But for the most part this is working.