More complex error codes logic for closing WebSocketConnections/WebSocketStreams #4
Closed
2 tasks done
Labels
development
Standard development
r&d:polykey:core activity 1
Secret Vault Sharing and Secret History Management
Specification
WebSocket/WebSocketConnection
Similarly to QUIC, when we close a
WebSocket
we can provide a code and message. When closing during normal operation we provide a code of1000
to imply normal closing.The Node
ws
library allows us to provide a type of Buffer or string for thereason
. However, the spec states that it must be a utf-8 encoded string, and the browserWebSocket
class will only accept a string as a valid reason for.close(code, reason)
.Error Codes
The
WebSocket
instance or may not use the predefined IANA defined close codes when closing a connection based on an error of some sort. We will be using these codes in the 1000-1999 space to define our errors.IANA gives applications the space of 4000 - 4999 for error codes, these will be what we recommend to the user for stopping a
WebSocketConnection
.WebSocketStream
Similarly to QUIC the WebSocketStream spec defined in #2 only has error codes, with all application level errors produced by the user of the API converted with the injected
codeToReason
andreasonToCode
functions.To note is that the ReadableStream and the WritableStream can be closed independently. When calling
.error
on a WebStream, a message should be sent to the peer with a shutdown byte that represents whether theReadableStream
or theWritableStream
of the peer should be given the errorError Codes
These are the following non-application errors:
All non-application errors will not be handled by the injected
codeToReason
andreasonToCode
functions.Additional context
Tasks
WebSocketConnection
with error codes and reasonsWebSocketStream
on Readable or Writable sides independentlyThe text was updated successfully, but these errors were encountered: