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
In the event that a node detects violation of a protocol or is unable to
5
-
complete the necessary steps required for the protocol, it's useful to provide a
6
-
reason for disconnection to the other end. This error code can be sent on both
7
-
Connection Close and Stream Reset. Its purpose is similar to http response
8
-
status. A server, on receiving an invalid request can reset the stream providing
9
-
a `BAD_REQUEST` error code, when it's busy handling too many requests can
10
-
provide a `RATE_LIMITED` error code, etc. An error code doesn't always indicate
11
-
an error condition. For example, a connection may be closed prematurely because
12
-
a connection to the same peer on a better transport is available.
15
+
16
+
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 on a better transport is available.
13
17
14
18
## Semantics
15
-
Error codes are unsigned 32bit integers. The range 0 to 10000 is reserved for
19
+
Error codes are unsigned 32-bit integers. The range 0 to 10000 is reserved for
16
20
libp2p errors. Application specific errors can be defined by protocols from
17
21
integers outside of this range. Implementations supporting error codes MUST
18
22
provide the error code provided by the other end to the application.
19
23
20
-
Error codes provide a best effort guarantee that the error will be propogated to
21
-
the applciation layer. This provides backwards compatibility with older nodes,
22
-
allows smaller implementations and using transports that don't provide a
24
+
Error codes provide a best effort guarantee that the error will be propagated to
25
+
the application layer. This provides backwards compatibility with older nodes,
26
+
allows smaller implementations, and using transports that don't provide a
23
27
mechanism to provide an error code. For example, Yamux has no equivalent of
Note: On TCP connections with `SO_LINGER` set to 0, the error code on connection
75
-
close may not be delivered.
76
+
Note: On TCP connections with `SO_LINGER` set to 0, the Connection Close error code may not be delivered.
76
77
77
78
### WebRTC
78
-
Since WebRTC doesn't provide reliable delivery for frames that are followed by
79
-
closing of the underlying data channel, there's no simple way to introduce error
80
-
codes in the current implementation. Consider the most common use case of
81
-
resetting both read and write sides of the stream and closing the data channel.
82
-
The chrome implementation will not deliver the final `RESET_STREAM` msg and
83
-
while the go implementation will delivery the `RESET_STREAM` frame and then
84
-
close the data channel, there's no guarantee that the chrome implementation will
85
-
provide the `RESET_STREAM` msg to the application layer after it receives the
86
-
data channel close message.
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.
80
+
81
+
For Stream Resets, the error code can be sent in the `errorCode` field of the WebRTC message with `flag` set to `RESET_STREAM` .
87
82
88
83
### WebTransport
89
-
Error codes for webtransport will be introduced when browsers upgrade to draft-9
90
-
of the spec. The current webtransport spec implemented by chrome and firefox is
0 commit comments