Close a connection is sending fails.
continuous-integration/drone/push Build is passing Details
continuous-integration/drone/pr Build is passing Details

This commit is contained in:
Sarah Jamie Lewis 2022-03-29 11:35:50 -07:00
parent abfa95cddb
commit 7fd53a3b16
1 changed files with 15 additions and 1 deletions

View File

@ -153,7 +153,21 @@ func (pa *PeerApp) SendMessage(message model2.PeerMessage) error {
}
if err == nil {
return pa.connection.Send(serialized)
err = pa.connection.Send(serialized)
// at this point we have tried to send a connection to a peer only to find that something went wrong.
// we don't know *what* went wrong - the most likely explanation is the peer went offline in the time between
// sending the message and it arriving in the engine to be sent. Other explanations include problems with Tor,
// a dropped wifi connection.
// Regardless, we error out this message and close this peer app assuming it cannot be used again.
// We expect that cwtch will eventually recreate this connection and the app.
if err != nil {
// close any associated sockets
pa.connection.Close()
// tell cwtch this connection is no longer valid
pa.OnClose(err.Error())
}
return err
}
return err
}