user3668129
user3668129

Reputation: 4820

exception - java.nio.channels.ClosedChannelException

I'm working with nio (non blocking mode).

when the server is down, and I'm trying to connect (after I'm getting isConnectable key) i'm getting the following exception: java.nio.channels.ClosedChannelException.

Every 1 second, I'm trying to reconnect to the server (via connect method) and getting the same exception: java.nio.channels.ClosedChannelException.

When the server is up , I'm getting the same exception and cant connect to the server.

  1. I don't understand why I'm getting the exception when later the server is ON ?
  2. How can I solve it, (How can I try to reconnect to the server ?)

Thanks

Upvotes: 1

Views: 5749

Answers (1)

user207421
user207421

Reputation: 311039

The SocketChannel is closed. You closed it, in your code, and then continued to use it. Or possibly you overlooked a ConnectException.

Upvotes: 1

Related Questions