Eh… after hours of debugging and thinking – the answer turned out to be the most obvious one – both clients I have been using were closing the connection (probably timeout). It worked in wget and postman while using swagger and advanced rest client caused the exception to be thrown.