2

i have a problem with java, this problem is really strange..im write a client server application, this server suppor login function, after login i can use the application, the problem is that, if i not use the app for 10 minutes when i try to do somethings on the app , i see Connection Reset error on the stack log, the problem appear ONLY if i not use the app for 10 minutes, after 10 minutes for re use the app i must do again the login.. i cant post the code is over 5000 lines.. how i can solve that problem?

Salvosnake
  • 83
  • 10
  • 1
    Try to use a tcp-keep-alive http://en.wikipedia.org/wiki/Keepalive#TCP_keepalive. – Grim May 13 '14 at 13:46
  • possible duplicate of [Java: socket read time out exception](http://stackoverflow.com/questions/12406628/java-socket-read-time-out-exception) – Evan Knowles May 13 '14 at 13:47
  • @EvanKnowles doesn't look like a duplicate to me. This appears to be about keeping a connection alive. – Duncan Jones May 13 '14 at 13:48
  • i not have timeout exception but connection reset exception after 10 minutes when i try to read on the socket , i send a byte on the client after i have sended a byte i wait for the client answer and when i try to read i have this exception.. – Salvosnake May 13 '14 at 13:59

1 Answers1

1

Try using this: http://docs.oracle.com/javase/7/docs/api/java/net/Socket.html#setKeepAlive(boolean).

public void setKeepAlive(boolean on)
                  throws SocketException
Enable/disable SO_KEEPALIVE.
Parameters:
on - whether or not to have socket keep alive turned on.
Buffalo
  • 3,861
  • 8
  • 44
  • 69
  • someone fixed something similar with this: Windows Control Panel > Installed Updated > Turn Windows Features on or Off > (CheckBox) Simple TCPIP services (i.e. echo, daytime etc) – Buffalo May 14 '14 at 06:35