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.

Mahmoud Hany
  • 139
  • 1
  • 11
  • 1
    Does this answer your question? [How to fix java.net.SocketException: Broken pipe?](https://stackoverflow.com/questions/2309561/how-to-fix-java-net-socketexception-broken-pipe) – Locke Mar 09 '21 at 04:37
  • Unclear what your actual difficulty is, but the idea is to fix the distributed application so it doesn't cause this error. – user207421 Mar 09 '21 at 06: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. – Mahmoud Hany Mar 09 '21 at 13:49
  • also my problem is just that the try catch statement is not working for this exception – Mahmoud Hany Mar 09 '21 at 15:49

1 Answers1

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

  • 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? – Mahmoud Hany Mar 09 '21 at 04:57
  • It has nothing to do with timeouts. – user207421 Mar 09 '21 at 06:16