try catch around reading and writing

which makes the channels more robust against lost connections