Socket Exception trying to use Debugger in PyCharm
Hey,
I am trying to develop a Plugin for PyCharm that uses the extension points of the Python Debugger.
When I run my plugin, PyCharm opens, and when I try to use the debugger there, I get the following exception:2024-04-24 11:03:41,145 [ 32603] WARN - #c.j.p.d.p.MultiProcessDebugger - Socket closed
java.net.SocketException: Socket closed
at java.base/sun.nio.ch.NioSocketImpl.endAccept(NioSocketImpl.java:694)
at java.base/sun.nio.ch.NioSocketImpl.accept(NioSocketImpl.java:767)
at java.base/java.net.ServerSocket.implAccept(ServerSocket.java:675)
at java.base/java.net.ServerSocket.platformImplAccept(ServerSocket.java:641)
at java.base/java.net.ServerSocket.implAccept(ServerSocket.java:617)
at java.base/java.net.ServerSocket.implAccept(ServerSocket.java:574)
at java.base/java.net.ServerSocket.accept(ServerSocket.java:532)
at com.jetbrains.python.debugger.pydev.transport.ServerModeDebuggerTransport.waitForConnect(ServerModeDebuggerTransport.java:39)
at com.jetbrains.python.debugger.pydev.RemoteDebugger.waitForConnect(RemoteDebugger.java:118)
at com.jetbrains.python.debugger.pydev.MultiProcessDebugger$DebuggerProcessAcceptor.run(MultiProcessDebugger.java:530)
at com.intellij.openapi.application.impl.ApplicationImpl$2.run(ApplicationImpl.java:249)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
at com.intellij.util.concurrency.ContextCallable.call(ContextCallable.java:32)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at com.intellij.util.concurrency.ContextRunnable.run(ContextRunnable.java:27)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:702)
at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:699)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1.run(Executors.java:699)
at java.base/java.lang.Thread.run(Thread.java:840)
Anyone has an idea, what is wrong with my setup?
I am developing in IntelliJ IDEA Build #IU-241.14494.240 and the platform version for the target PyCharm CE is 2023.3.3 currently.
Thanks for your help.
Please sign in to leave a comment.
Hi Julian,
Please share the code and describe exact steps to reproduce the issue.
Hi Karol Lewandowski !
I just used the template code from GitHub for a new Plugin and set the target platform to PC in the gradle.properties. Then, I used the runIde Gradle Task to run my plugin. After PyCharm has started, I opened a small dummy Python Project and tried to run the Python script with the Python Debugger. My IntelliJ throws the SocketException then. At least, that's the easiest way for me to reproduce the issue.
Do you need anything else?
Thanks for your help in advance!
Hi Julian,
It's still too general. What project did you open? What run configuration did you run? What script? Does the same issue happen for the same project and run configuration in a non-plugin-development environment?
Also, you mentioned that you are trying to implement a plugin that “uses the extension points of the Python Debugger”. Did you start implementing it, or is it just a plan, and nothing has been done yet?
Hey Karol Lewandowski ! Thanks for your answer! :-)
I will try to clearify things:
Okay, it looks like the issue came from an error of the Python Debugger that obviously got fixed. The SocketException was thrown because the socket was closed immidiately after starting the debugging process without any traffic between client and server.
After the bug was fixed, everything works fine now. I didn't have to make any changes to make it work.