1

I was working on a java program (can't show the code) even tho I'm not experienced with sockets, anyways I keep getting an exception I can't seem to be able to catch.

all the exception says is: "java.net.SocketException: Broken Pipe".

any ideas?

EDIT:

sorry for not being clear I'm trying to use try/catch statement on that exception because my program expects the other end to disconnect at some point but I don't want that to kill my application.

EDIT 2

oh I feel so stupid right now, after hours of debugging I finally found out that I indeed can catch the exception, I just had to look in the right place, sorry for the noise everyone.

thanks.

4
  • 1
    Does this answer your question? How to fix java.net.SocketException: Broken pipe? Commented Mar 9, 2021 at 4:37
  • Unclear what your actual difficulty is, but the idea is to fix the distributed application so it doesn't cause this error. Commented Mar 9, 2021 at 6:16
  • @user207421 the idea behind what I'm trying to achieve is when the client and server are already connected. the client/server will write/receive data at some point but when the server disconnects the only way for the client to know that the server is dead is by catching this exception when it does that it can retry connection to the server. hope the info helps. Commented Mar 9, 2021 at 13:49
  • also my problem is just that the try catch statement is not working for this exception Commented Mar 9, 2021 at 15:49

1 Answer 1

0

It's may happen when the server timeout for a request connection has been finished. In most of the times uploading large resource cause this issue. you have to make your API to be ok with long-duration request timeout

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

2 Comments

hmm, I don't know if I understand you correctly as I said I'm not very experienced, what I'm trying to do is have the client application send data and also detect when the server is down so it can attempt re-connection, do you maybe have any examples for a newbie?
It has nothing to do with timeouts.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.