After playing some time (ten minutes or so) the client said the server had disconnected. I checked the server and found the java exception. When trying to reconnect the server rejected connection. I restarted both the server and client and after playing some time the story repeats.
I tried to reproduce the suggested duplicate issue MC-37175. I disconnected and reconnected to a server several (10) times without any problem. This could indicate that this is completely different problem.
I now changed the player-idle-timeout setting in the server.properties file from 0 to 30. So far it seems to remove the problem with io.netty.handler.timeout.ReadTimeoutException