diff --git a/src/peer_connection.cpp b/src/peer_connection.cpp
index ecd6a826e84cc63a7b09bf641ec7e74285076139..4b0fa7b81888bbff5e28ff86df271c11d131935f 100644
--- a/src/peer_connection.cpp
+++ b/src/peer_connection.cpp
@@ -529,8 +529,12 @@ PeerConnection::PeerConnectionImpl::eventLoop()
         handle_stream_list(inputs_, [&](auto& stream){
                 if (!stream->read(buf))
                     return false;
-                endpoint_->write(buf, ec);
-                return true;
+                auto size = endpoint_->write(buf, ec);
+                if (!ec)
+                    return true;
+                if (!size)
+                    return false;
+                throw std::system_error(ec);
             });
         handle_stream_list(outputs_, [&](auto& stream){
                 endpoint_->read(buf, ec);