rpc: handle response with Identify opcode as retryable
Sometimes arRPC would just send a response with the Identify opcode and `{"cmd":""}`. It is unclear what causes this and the easiest way to recover that I'm aware of is to close the connection and start a fresh one. Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
This commit is contained in:
parent
72d6a8e95c
commit
8a975f9a31
14
rpc.go
14
rpc.go
@ -146,8 +146,18 @@ func validateRaw[T nonceEventCommandTracer](opcode uint32, event, command, nonce
|
|||||||
if err == nil {
|
if err == nil {
|
||||||
switch {
|
switch {
|
||||||
case opcodeR != opcode:
|
case opcodeR != opcode:
|
||||||
debugResponse(resp)
|
// the socket is still open however
|
||||||
err = fmt.Errorf("received unexpected opcode %d", opcodeR)
|
// as far as I'm aware this state is not recoverable
|
||||||
|
// therefore we close the connection and advise a retry
|
||||||
|
if opcodeR == Identify {
|
||||||
|
// clean up as much as possible
|
||||||
|
_ = d.Close()
|
||||||
|
// advise retry
|
||||||
|
err = ErrAgain
|
||||||
|
} else {
|
||||||
|
debugResponse(resp)
|
||||||
|
err = fmt.Errorf("received unexpected opcode %d", opcodeR)
|
||||||
|
}
|
||||||
case !resp.nonce(nonce):
|
case !resp.nonce(nonce):
|
||||||
err = ErrNonce
|
err = ErrNonce
|
||||||
case eventR != nil:
|
case eventR != nil:
|
||||||
|
Loading…
Reference in New Issue
Block a user