0

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.

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

I'm logging actions from server side because I'm not running any IDE debug there. It should log when a message is received but it keeps waiting for inputstream to fill. On the client side, the debugger is apparently detached when I call getOutputStream and no exception is thrown but apparently the PrintWriter which should write the message doesn't even initialize. I'm making some client-server raw tests, I'll see tomorrow if I can find a way out.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.