You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When closing a connection or resetting a stream, it's useful to provide the peer with a code that explains the reason for the closure. This enables the peer to better respond to the abrupt closures. For instance, it can implement a backoff strategy to retry _only_ when it receives a `RATE_LIMITED` error code. An error code doesn't always indicate an error condition. For example, a connection may be closed because a connection to the same peer over a better transport is available.
16
+
When closing a connection or resetting a stream, it's useful to provide the peer
17
+
with a code that explains the reason for the closure. This enables the peer to
18
+
better respond to the abrupt closures. For instance, it can implement a backoff
19
+
strategy to retry _only_ when it receives a `RATE_LIMITED` error code. An error
20
+
code doesn't always indicate an error condition. For example, a connection may
21
+
be closed because a connection to the same peer over a better transport is
22
+
available.
17
23
18
24
## Semantics
19
25
Error codes are unsigned 32-bit integers. The range 0 to 10000 is reserved for
@@ -42,10 +48,12 @@ Close error code on streams that are reset as a result of remote closing the
42
48
connection.
43
49
44
50
For stream resets, when the underlying transport supports it, implementations
45
-
SHOULD allow sending an error code on both closing the read side of the stream, and resetting the write side of the stream.
51
+
SHOULD allow sending an error code on both closing the read side of the stream,
52
+
and resetting the write side of the stream.
46
53
47
-
## Libp2p Error Codes
48
-
TODO!
54
+
## Libp2p Reserved Error Codes
55
+
see [Libp2p error codes](./libp2p-error-codes.md) for the libp2p reserved error
56
+
codes.
49
57
50
58
## Wire Encoding
51
59
Different transports will encode the 32-bit error code differently.
@@ -67,18 +75,22 @@ using the Error Code field as defined in the
67
75
Yamux has no `STOP_SENDING` frame, so there's no way to signal an error on
68
76
closing the read side of the stream.
69
77
70
-
For Connection Close, the 32-bit Length field is interpreted as the error
71
-
code.
78
+
For Connection Close, the 32-bit Length field is interpreted as the error code.
72
79
73
-
For Stream Resets, the error code is sent in the `Window Update` frame, with the 32-bit Length field interpreted as the error code. See [yamux spec
80
+
For Stream Resets, the error code is sent in the `Window Update` frame, with the
81
+
32-bit Length field interpreted as the error code. See [yamux spec
Note: On TCP connections with `SO_LINGER` set to 0, the Connection Close error code may not be delivered.
84
+
Note: On TCP connections with `SO_LINGER` set to 0, the Connection Close error
85
+
code may not be delivered.
77
86
78
87
### WebRTC
79
-
There is no way to provide any information on closing a peer connection in WebRTC. Providing error codes on Connection Close will be taken up in the future.
88
+
There is no way to provide any information on closing a peer connection in
89
+
WebRTC. Providing error codes on Connection Close will be taken up in the
90
+
future.
80
91
81
-
For Stream Resets, the error code can be sent in the `errorCode` field of the WebRTC message with `flag` set to `RESET_STREAM` .
92
+
For Stream Resets, the error code can be sent in the `errorCode` field of the
93
+
WebRTC message with `flag` set to `RESET_STREAM` .
82
94
83
95
### WebTransport
84
96
Error codes for WebTransport will be introduced when browsers upgrade to draft-9
0 commit comments