diff --git a/rpc.go b/rpc.go index 31a1136..57b2258 100644 --- a/rpc.go +++ b/rpc.go @@ -146,8 +146,18 @@ func validateRaw[T nonceEventCommandTracer](opcode uint32, event, command, nonce if err == nil { switch { case opcodeR != opcode: - debugResponse(resp) - err = fmt.Errorf("received unexpected opcode %d", opcodeR) + // the socket is still open however + // 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): err = ErrNonce case eventR != nil: