我一直試圖運行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.