简体   繁体   中英

Java/Android - Getting socket output stream breaks execution with no exception launched

I'm debugging the thread which manages a socket and I noticed that when I call getOutputStream() the debug breaks with no exception thrown. I've even added breakpoints to the very Socket.getOutputStream() but there is no way to get what's wrong. The Java server correctly accepts the connection and waits for input (by checking inputStream.available()). Both Socket and ServerSocket come from SSLSocketFactory and SSLServerSocketFactory.

I'm using Android Studio.

What am I doing wrong?

edit: I've even tried to change structure from Thread to AsyncTask but the result is the same. This is frustrating.

Debugging network connections is a bit tricky as time-outs may occur.

I am also unsure if breakpoints on non-app-code (like Socket.getOutputStream() ) will really work. The SDK code in AndroidStudio may be different to the one used by your devices which mean that breakpoints (which are set to a specific line) may end up in a totally different method (if they work at all).

Therefore I would suggest to change your code and add log statements and if necessary sleep commands to slow-down the important parts.

For SSL traffic I strongly suggest to look also at the transferred data. There are apps capturing the traffic on-device that run without root permissions. Later you can then debug the traffic on the PC using Wireshark and see if the problem was caused by a communication problem between your client and the server.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM