我一直试图运行jdb试图让它连接到我的android设备上的进程。是jdb给java.net.SocketException:连接重置
我试过的命令如下:
adb forward tcp:12345 jdwp:4127
jdb -connect com.sun.jdi.SocketAttach:hostname=localhost,port=12345
我们可以假设具有PID 4127这个进程仍然活着。
然而,进入2个命令后,我收到了错误信息如下:
java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(SocketInputStream.java:209)
at java.net.SocketInputStream.read(SocketInputStream.java:141)
at com.sun.tools.jdi.SocketTransportService.handshake(SocketTransportService.java:130)
at com.sun.tools.jdi.SocketTransportService.attach(SocketTransportService.java:232)
at com.sun.tools.jdi.GenericAttachingConnector.attach(GenericAttachingConnector.java:116)
at com.sun.tools.jdi.SocketAttachingConnector.attach(SocketAttachingConnector.java:90)
at com.sun.tools.example.debug.tty.VMConnection.attachTarget(VMConnection.java:519)
at com.sun.tools.example.debug.tty.VMConnection.open(VMConnection.java:328)
at com.sun.tools.example.debug.tty.Env.init(Env.java:63)
at com.sun.tools.example.debug.tty.TTY.main(TTY.java:1066)
我注意到一个奇怪的现象是,当我的应用程序1运行该输出只发生。这可能是由于程序运行时线程或进程或端口的冲突?
我可以得到下面的输出大部分的时候,我那个特定的应用程序被关闭:
Set uncaught java.lang.Throwable
Set deferred uncaught java.lang.Throwable
Initializing jdb ...
> Input stream closed.
我也尝试使用以下步骤运行在管理员模式下的命令提示符:
netsh advfirewall set global StatefulFTP disable
adb forward tcp:12345 jdwp:4127
jdb -connect com.sun.jdi.SocketAttach:hostname=localhost,port=12345
输出如下:
java.io.IOException: handshake failed - connection prematurally closed
at com.sun.tools.jdi.SocketTransportService.handshake(SocketTransportService.java:136)
at com.sun.tools.jdi.SocketTransportService.attach(SocketTransportService.java:232)
at com.sun.tools.jdi.GenericAttachingConnector.attach(GenericAttachingConnector.java:116)
at com.sun.tools.jdi.SocketAttachingConnector.attach(SocketAttachingConnector.java:90)
at com.sun.tools.example.debug.tty.VMConnection.attachTarget(VMConnection.java:519)
at com.sun.tools.example.debug.tty.VMConnection.open(VMConnection.java:328)
at com.sun.tools.example.debug.tty.Env.init(Env.java:63)
at com.sun.tools.example.debug.tty.TTY.main(TTY.java:1066)
Fatal error:
Unable to attach to target VM.