Close the connection and re-emit the event if the socket times out. Related to #1909
Merge branch 'michel_1909_timeout' into next