connection fix: stream writer does not wait until all bytes are received