Skip to content

Commit ec31e90

Browse files
Specify exact error codes (rsocket#213)
Solve SETUP_ERROR confusion: rsocket/rsocket#191 Exactly specify what error codes are applicable any time an ERROR frame is referenced.
1 parent cfd66ab commit ec31e90

File tree

1 file changed

+45
-43
lines changed

1 file changed

+45
-43
lines changed

Protocol.md

Lines changed: 45 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ __NOTE__: Byte ordering is big endian.
166166
#### Handling Ignore Flag
167167

168168
The (__I__)gnore flag is used for extension of the protocol. A value of 0 in a frame for this flag indicates the protocol can't
169-
ignore this frame. An implementation MAY send an ERROR frame (with CONNECTION_ERROR error code) and close the underlying transport
169+
ignore this frame. An implementation MAY send an ERROR[CONNECTION_ERROR] frame and close the underlying transport
170170
connection on reception of a frame that it does not understand with this bit not set.
171171

172172
#### Frame Validation
@@ -302,13 +302,12 @@ rules MAY be used for handling layout. For example, `application/x.netflix+cbor`
302302
* __Setup Data__: includes payload describing connection capabilities of the endpoint sending the
303303
Setup header.
304304

305-
__NOTE__: A server that receives a SETUP frame that has (__R__)esume Enabled set, but does not support resuming operation, MUST reject the SETUP with an ERROR.
305+
__NOTE__: A server that receives a SETUP frame that has (__R__)esume Enabled set, but does not support resuming operation, MUST reject the SETUP with an ERROR[REJECTED_SETUP].
306306

307307
<a name="frame-error"></a>
308308
### ERROR Frame (0x0B)
309309

310-
Error frames are used for errors on individual requests/streams as well as connection errors and in response
311-
to SETUP frames. The latter is referred to as a SETUP_ERROR.
310+
Error frames are used for errors on individual requests/streams as well as connection errors and in response to SETUP frames.
312311

313312
Frame Contents
314313

@@ -332,8 +331,7 @@ Frame Contents
332331
* See list of valid Error Codes below.
333332
* __Error Data__: includes Payload describing error information. Error Data SHOULD be a UTF-8 encoded string. The string MUST NOT be null terminated.
334333

335-
A Stream ID of 0 means the error pertains to the connection. Including connection establishment. A Stream ID > 0
336-
means the error pertains to a given stream.
334+
A Stream ID of 0 means the error pertains to the connection., including connection establishment. A Stream ID > 0 means the error pertains to a given stream.
337335

338336
The Error Data is typically an Exception message, but could include stringified stacktrace information if appropriate.
339337

@@ -356,6 +354,14 @@ The Error Data is typically an Exception message, but could include stringified
356354

357355
__NOTE__: Unsed values in the range of 0x0001 to 0x00300 are reserved for future protocol use. Values in the range of 0x00301 to 0xFFFFFFFE are reserved for application layer errors.
358356

357+
When this document refers to a specific Error Code as a frame, it uses this pattern: ERROR[error_code] or ERROR[error_code|error_code]
358+
359+
For example:
360+
361+
- ERROR[INVALID_SETUP] means the ERROR frame with the INVALID_SETUP code
362+
- ERROR[REJECTED] means the ERROR frame with the REJECTED code
363+
- ERROR[CONNECTION_ERROR|REJECTED_RESUME] means the ERROR frame either either the CONNECTION_ERROR or REJECTED_RESUME code
364+
359365
<a name="frame-lease"></a>
360366
### LEASE Frame (0x02)
361367

@@ -696,28 +702,26 @@ All ERROR frames sent MUST be CONNECTION_ERROR or REJECTED_RESUME error code.
696702
Client side resumption operation starts when the client desires to try to resume and starts a new transport connection. The operation then proceeds as the following:
697703

698704
* Client sends RESUME frame. The client MUST NOT send any other frame types until resumption succeeds. The RESUME Identification Token MUST be the token used in the original SETUP frame. The RESUME Last Received Position field MUST be the last successfully received implied position from the server.
699-
* Client waits for either a RESUME_OK or ERROR frame from the server.
700-
* On receiving an ERROR frame, the client MUST NOT attempt resumption again if the error code was REJECTED_RESUME.
705+
* Client waits for either a RESUME_OK or ERROR[CONNECTION_ERROR|REJECTED_RESUME] frame from the server.
706+
* On receiving an ERROR[REJECTED_RESUME] frame, the client MUST NOT attempt resumption again.
701707
* On receiving a RESUME_OK, the client:
702708
* MUST assume that the next REQUEST, CANCEL, ERROR, and PAYLOAD frames have an implied position commencing from the last implied positions
703709
* MAY retransmit *all* REQUEST, CANCEL, ERROR, and PAYLOAD frames starting at the RESUME_OK Last Received Position field value from the server.
704-
* MAY send an ERROR frame indicating the end of the connection and MUST NOT attempt resumption again
710+
* MAY send an ERROR[CONNECTION_ERROR|CONNECTION_CLOSE] frame indicating the end of the connection and MUST NOT attempt resumption again
705711

706712
Server side resumption operation starts when the client sends a RESUME frame. The operation then proceeds as the following:
707713

708714
* On receiving a RESUME frame, the server:
709-
* MUST send an ERROR frame if the server does not support resuming operation. This is accomplished by handling the Ignore bit in the RESUME frame.
710-
* use the RESUME Identification Token field to determine which client the resume pertains to. If the client is identified successfully, resumption MAY be continued. If not identified, then the server MUST send an ERROR frame.
715+
* MUST send an ERROR[REJECTED_RESUME] frame if the server does not support resuming operation. This is accomplished by handling the Ignore bit in the RESUME frame.
716+
* use the RESUME Identification Token field to determine which client the resume pertains to. If the client is identified successfully, resumption MAY be continued. If not identified, then the server MUST send an ERROR[REJECTED_RESUME] frame.
711717
* if successfully identified, then the server MAY send a RESUME_OK and then:
712718
* MUST assume that the next REQUEST, CANCEL, ERROR, and PAYLOAD frames have an implied position commencing from the last implied positions
713719
* MAY retransmit *all* REQUEST, CANCEL, ERROR, and PAYLOAD frames starting at the RESUME Last Received Position field value from the client.
714-
* if successfully identified, then the server MAY send an ERROR frame if the server can not resume operation given the value of RESUME Last Received Position if the position is not one it deems valid to resume operation from or other extenuating circumstances.
715-
716-
A Server that receives a RESUME frame after a SETUP frame, SHOULD send an ERROR.
720+
* if successfully identified, then the server MAY send an ERROR[REJECTED_RESUME] frame if the server can not resume operation given the value of RESUME Last Received Position if the position is not one it deems valid to resume operation from or other extenuating circumstances.
717721

718-
A Server that receives a RESUME frame after a previous RESUME frame, SHOULD send an ERROR.
722+
A Server that receives a RESUME frame after a SETUP frame, SHOULD send an ERROR[CONNECTION_ERROR].
719723

720-
A Server implementation MAY use CONNECTION_ERROR or REJECTED_RESUME as it sees fit for each error condition.
724+
A Server that receives a RESUME frame after a previous RESUME frame, SHOULD send an ERROR[CONNECTION_ERROR].
721725

722726
Leasing semantics are NOT assumed to carry over from previous connections when resuming. LEASE semantics MUST be restarted upon a new connection by sending a LEASE frame from the server.
723727

@@ -804,12 +808,11 @@ The requirements for the Resume Identification Token are implementation dependen
804808

805809
__NOTE__: The semantics are similar to [TLS False Start](https://tools.ietf.org/html/draft-bmoeller-tls-falsestart-00).
806810

807-
The term SETUP_ERROR is used below to indicate an ERROR frame that has a Stream ID of 0 and an Error Code
808-
that indicates a SETUP error.
811+
Immediately upon successful connection, the client MUST send either a SETUP or RESUME frame with
812+
Stream ID of 0. Any other frame received that is NOT a SETUP|RESUME frame or a SETUP|RESUME frame with
813+
a Stream ID > 0, MUST cause the server to send an ERROR[INVALID_SETUP] and close the connection.
809814

810-
Immediately upon successful connection, the client MUST send a SETUP frame with
811-
Stream ID of 0. Any other frame received that is NOT a SETUP frame or a SETUP frame with
812-
a Stream ID > 0, MUST cause the server to send a SETUP_ERROR (with INVALID_SETUP) and close the connection.
815+
See [Resume Operation](#resume-operation) for more information about resuming. The rest of this section assumes use of SETUP for establishing a connection.
813816

814817
The client-side Requester can inform the server-side Responder as to whether it will
815818
honor LEASEs or not based on the presence of the __L__ flag in the SETUP frame.
@@ -825,7 +828,7 @@ the SETUP frame set the __L__ flag. The server-side Requester may send requests
825828
immediately upon receiving a SETUP frame that it accepts if the __L__ flag is not set in the SETUP frame.
826829

827830
If the server does NOT accept the contents of the SETUP frame, the server MUST send
828-
back a SETUP_ERROR and then close the connection.
831+
back an ERROR[INVALID_SETUP|UNSUPPORTED_SETUP] and then close the connection.
829832

830833
The __S__ flag of the SETUP indicates the client requires the server to adhere to strict interpretation
831834
of the Data and Metadata of the SETUP. Anything in the Data and/or Metadata that is not understood or can
@@ -839,7 +842,7 @@ send a LEASE frame after a SETUP frame with the __L__ flag set.
839842
A client assumes a SETUP is accepted if it receives a response to a request, a LEASE
840843
frame, or if it sees a REQUEST type.
841844

842-
A client assumes a SETUP is rejected if it receives a SETUP_ERROR.
845+
A client assumes a SETUP is rejected if it receives an ERROR.
843846

844847
Until connection establishment is complete, a Requester MUST NOT send any Request frames.
845848

@@ -848,7 +851,7 @@ Until connection establishment is complete, a Responder MUST NOT emit any PAYLOA
848851
### Negotiation
849852

850853
The assumption is that the client will be dictating to the server what it desires to do. The server will decide to support
851-
that SETUP (accept it) or not (reject it). The SETUP_ERROR error code indicates the reason for the rejection.
854+
that SETUP (accept it) or not (reject it). The ERROR[INVALID_SETUP|UNSUPPORTED_SETUP|REJECTED_SETUP] error code indicates the reason for the rejection.
852855

853856
### Sequences without LEASE
854857

@@ -859,13 +862,13 @@ The possible sequences without LEASE are below.
859862
* Server accepts SETUP, handles REQUEST, sends back normal sequence based on REQUEST type
860863
1. Client-side Request, Server-side __rejects__ SETUP
861864
* Client connects & sends SETUP & sends REQUEST
862-
* Server rejects SETUP, sends back SETUP_ERROR, closes connection
865+
* Server rejects SETUP, sends back ERROR[INVALID_SETUP|UNSUPPORTED_SETUP|REJECTED_SETUP], closes connection
863866
1. Server-side Request, Server-side __accepts__ SETUP
864867
* Client connects & sends SETUP
865868
* Server accepts SETUP, sends back REQUEST type
866869
1. Server-side Request, Server-side __rejects__ SETUP
867870
* Client connects & sends SETUP
868-
* Server rejects SETUP, sends back SETUP_ERROR, closes connection
871+
* Server rejects SETUP, sends back ERROR[INVALID_SETUP|UNSUPPORTED_SETUP|REJECTED_SETUP], closes connection
869872

870873
### Sequences with LEASE
871874

@@ -877,15 +880,15 @@ The possible sequences with LEASE are below.
877880
* Client-side sends REQUEST
878881
1. Client-side Request, Server-side __rejects__ SETUP
879882
* Client connects & sends SETUP with __L__ flag
880-
* Server rejects SETUP, sends back SETUP_ERROR, closes connection
883+
* Server rejects SETUP, sends back ERROR[INVALID_SETUP|UNSUPPORTED_SETUP|REJECTED_SETUP], closes connection
881884
1. Server-side Request, Server-side __accepts__ SETUP
882885
* Client connects & sends SETUP with __L__ flag
883886
* Server accepts SETUP, sends back LEASE frame
884887
* Client sends LEASE frame
885888
* Server sends REQUEST
886889
1. Server-side Request, Server-side __rejects__ SETUP
887890
* Client connects & sends SETUP with __L__ flag
888-
* Server rejects SETUP, sends back SETUP_ERROR, closes connection
891+
* Server rejects SETUP, sends back ERROR[INVALID_SETUP|UNSUPPORTED_SETUP|REJECTED_SETUP], closes connection
889892

890893
## Fragmentation And Reassembly
891894

@@ -945,7 +948,7 @@ Once a stream has "terminated", the Stream ID can be "forgotten" by the Requeste
945948
or
946949

947950
1. RQ -> RS: REQUEST_RESPONSE
948-
1. RS -> RQ: ERROR
951+
1. RS -> RQ: ERROR[APPLICATION_ERROR|REJECTED|INVALID]
949952

950953
or
951954

@@ -958,7 +961,7 @@ Upon receiving a CANCEL, the stream is terminated on the Responder and the respo
958961

959962
Upon sending a CANCEL, the stream is terminated on the Requester.
960963

961-
Upon receiving a COMPLETE or ERROR, the stream is terminated on the Requester.
964+
Upon receiving a COMPLETE or ERROR[APPLICATION_ERROR|REJECTED|INVALID], the stream is terminated on the Requester.
962965

963966
<a name="stream-sequences-fire-and-forget"></a>
964967
### Request Fire-n-Forget
@@ -976,7 +979,7 @@ REQUEST_FNF are assumed to be best effort and MAY not be processed due to: (1) S
976979

977980
1. RQ -> RS: REQUEST_STREAM
978981
1. RS -> RQ: PAYLOAD*
979-
1. RS -> RQ: ERROR
982+
1. RS -> RQ: ERROR[APPLICATION_ERROR|REJECTED|INVALID]
980983

981984
or
982985

@@ -996,9 +999,9 @@ Upon receiving a CANCEL, the stream is terminated on the Responder.
996999

9971000
Upon sending a CANCEL, the stream is terminated on the Requester.
9981001

999-
Upon receiving a COMPLETE or ERROR, the stream is terminated on the Requester.
1002+
Upon receiving a COMPLETE or ERROR[APPLICATION_ERROR|REJECTED|INVALID], the stream is terminated on the Requester.
10001003

1001-
Upon sending a COMPLETE or ERROR, the stream is terminated on the Responder.
1004+
Upon sending a COMPLETE or ERROR[APPLICATION_ERROR|REJECTED|INVALID], the stream is terminated on the Responder.
10021005

10031006
<a name="stream-sequences-channel"></a>
10041007
### Request Channel
@@ -1018,7 +1021,7 @@ Upon sending a COMPLETE or ERROR, the stream is terminated on the Responder.
10181021

10191022
1. RQ -> RS: REQUEST_CHANNEL
10201023
1. RQ -> RS: PAYLOAD*
1021-
1. RQ -> RS: ERROR
1024+
1. RQ -> RS: ERROR[APPLICATION_ERROR]
10221025

10231026
intermixed with
10241027

@@ -1028,7 +1031,7 @@ Upon sending a COMPLETE or ERROR, the stream is terminated on the Responder.
10281031

10291032
1. RQ -> RS: REQUEST_CHANNEL
10301033
1. RQ -> RS: PAYLOAD*
1031-
1. RQ -> RS: ERROR
1034+
1. RQ -> RS: ERROR[APPLICATION_ERROR]
10321035

10331036
intermixed with
10341037

@@ -1043,7 +1046,7 @@ Upon sending a COMPLETE or ERROR, the stream is terminated on the Responder.
10431046
intermixed with
10441047

10451048
1. RS -> RQ: PAYLOAD*
1046-
1. RS -> RQ: ERROR
1049+
1. RS -> RQ: ERROR[APPLICATION_ERROR|REJECTED|INVALID]
10471050

10481051
#### Error from Responder, Requester already Completed
10491052

@@ -1054,7 +1057,7 @@ Upon sending a COMPLETE or ERROR, the stream is terminated on the Responder.
10541057
intermixed with
10551058

10561059
1. RS -> RQ: PAYLOAD*
1057-
1. RS -> RQ: ERROR
1060+
1. RS -> RQ: ERROR[APPLICATION_ERROR|REJECTED|INVALID]
10581061

10591062
#### Cancel from Requester, Responder terminates
10601063

@@ -1079,9 +1082,9 @@ Upon receiving a CANCEL, the stream is terminated on the Responder.
10791082

10801083
Upon sending a CANCEL, the stream is terminated on the Requester.
10811084

1082-
Upon receiving an ERROR, the stream is terminated on both Requester and Responder.
1085+
Upon receiving an ERROR[APPLICATION_ERROR|REJECTED|INVALID], the stream is terminated on both Requester and Responder.
10831086

1084-
Upon sending an ERROR, the stream is terminated on both the Requester and Responder.
1087+
Upon sending an ERROR[APPLICATION_ERROR|REJECTED|INVALID], the stream is terminated on both the Requester and Responder.
10851088

10861089
In absence of ERROR or CANCEL, the stream is terminated after both Requester and Responder have sent and received COMPLETE.
10871090

@@ -1125,8 +1128,7 @@ is responsible for the logic of generation and informing the Responder it should
11251128
Requester MUST respect the LEASE contract. The Requester MUST NOT send more than __Number of Requests__ specified
11261129
in the LEASE frame within the __Time-To-Live__ value in the LEASE.
11271130

1128-
A Responder that receives a REQUEST that it can not honor due to LEASE restrictions MUST respond with an ERROR frame with error code
1129-
of LEASE_ERROR. This includes an initial LEASE sent as part of [Connection Establishment](#connection-establishment).
1131+
A Responder that receives a REQUEST that it can not honor due to LEASE restrictions MUST respond with an ERROR[LEASE_ERROR]. This includes an initial LEASE sent as part of [Connection Establishment](#connection-establishment).
11301132

11311133
<a name="flow-control-qos"></a>
11321134
#### QoS and Prioritization
@@ -1157,6 +1159,6 @@ assume it is set and act accordingly.
11571159
1. Receiving a PAYLOAD on an unknown Stream ID (including 0) MUST be ignored.
11581160
1. Receiving a METADATA_PUSH with a non-0 Stream ID MUST be ignored.
11591161
1. A server MUST ignore a SETUP frame after it has accepted a previous SETUP.
1160-
1. A server MUST ignore a SETUP_ERROR frame.
1161-
1. A client MUST ignore a SETUP_ERROR after it has completed connection establishment.
1162+
1. A server MUST ignore an ERROR[INVALID_SETUP|UNSUPPORTED_SETUP|REJECTED_SETUP|REJECTED_RESUME] frame.
1163+
1. A client MUST ignore an ERROR[INVALID_SETUP|UNSUPPORTED_SETUP|REJECTED_SETUP|REJECTED_RESUME] frame after it has completed connection establishment.
11621164
1. A client MUST ignore a SETUP frame.

0 commit comments

Comments
 (0)