fix(proxy): Correctly close connection pipe when dealing with error
This fix is mainly about closing properly the reader side of the pipe used in proxy to transmit data from the WebRTC DataChannel OnMessage
listener over to the webRTCConn
using it to "copy-loop" with the websocket connection to the relay.
Not closing it properly, for instance on error like "could not dial the relay" (which would happen when one of the relay is down
This blocking situation would then cause the OnMessage
event callback to never return, causing then the webrtc
library-suite to utterly fail at closing the connection since the read-loop used internally would be blocked on the onMessage
event signalling.
All this contributing to the recent situation of Snowflake proxies going berzerk (huge memory consumption and weird metrics) whenever a relay is down, which would hopefully be fixed by these changes.