The reason the second write failed is because the server closed the connection.
The reason the server closed the connection is because you failed to add the HTTP header
Connection: Keep-Alive
to the original request.
This is required in order to leave the channel open (which is what you want to do in this scenario).
Once a channel has been closed, you must create a new channel. You cannot reopen the channel. The ChannelFuture returned by Channel.getCloseFuture() is final (i.e., constant) to the channel and once isDone() on this future returns true
it cannot be reset. This is the reason that a closed channel cannot be reused.
However, you may reuse an open channel as many times as you need; but your application must talk the HTTP protocol properly in order to accomplish this.