Kibotos
API referenceHTTP endpoints

/v1/service

This page describes /v1/service on the node data plane. Its parameter names and limits are generated from the constants the Kibotos code implements it with.

Connects to one TCP loopback port or Unix stream socket in the guest over a WebSocket. ServiceConnectionService/Connect carries the same bytes as a bidirectional stream, where every hop supports HTTP/2 end to end.

Credential

  • Authorization: Bearer <credential>, with the credential of a data-plane session that has DATA_PLANE_SCOPE_SERVICE_CONNECT and lists the target in its service_targets.
  • A client that cannot set handshake headers, such as a browser, offers the subprotocol kibotos-dp-credential.<credential> in Sec-WebSocket-Protocol instead; the 101 response selects it. Exactly one such subprotocol is accepted.
  • Never put the credential in the query: it reaches access logs and the Referer header.

Methods

MethodScopeDescription
GETDATA_PLANE_SCOPE_SERVICE_CONNECTOpens the WebSocket. The credential is checked and the guest socket connected before the upgrade, so 101 means the socket is connected; a failure before that is an ordinary HTTP response with the error body. Other methods answer 405.

Query parameters

ParameterMethodsRequiredDescription
tcp_familyGETThe loopback address family of a TCP target, ipv4 or ipv6. Given with tcp_port.
tcp_portGETThe port of a TCP target, from 1 to 65535. Given with tcp_family.
unix_pathGETThe absolute path of a Unix stream socket target. Given alone.

The query names exactly one target, which must be one of the session's service_targets. Repeated parameters, or parameters of both kinds, answer 400.

Frames

OpcodeNameSent byPayloadDescription
0x00databothApplication bytes, not emptyBytes for the other side.
0x01half closeclientNoneThe client ends its write direction. It sends no data afterwards.
0x02end of streamserverNoneThe service in the guest ended its write direction. This is not a failure.

Every message is binary, and its first byte is the opcode.

A text message, an unknown opcode, an empty data frame, or end of stream from the client is a protocol error.

The server sends only data and end of stream. Opcodes added later go only to clients that declare them in the handshake, so a client may treat any other opcode as a protocol error.

Close codes

Close codeMeaning
1000Both directions ended. The reason is empty.
Any other codeThe connection failed. The reason starts with the lowercase Connect error code, the one ServiceConnectionService/Connect answers in the same situation, followed by : and a description when there is one.

Only 1000 means success. 1001, which many WebSocket libraries treat as a normal end, is a failure here: for example a reset from the service in the guest closes with 1001 and a reason starting with unavailable.

The reason is at most 123 bytes, the WebSocket limit; a longer one is cut.

A connection that ends without a close frame was interrupted. Treat it as a failure.

Bodies

Error body

The body of every error response, with Content-Type: application/json.

FieldTypeDescription
codestringThe name of the Connect error code, such as not_found.
detailobjectThe ErrorDetail of the error in protobuf JSON, with the field names of the proto file.

Status codes

HTTP statusConnect error codes
400invalid_argument
401unauthenticated
403permission_denied
404not_found
405unimplemented
409already_exists, failed_precondition, aborted
413resource_exhausted
499canceled
500unknown, out_of_range, internal, data_loss
503unavailable
504deadline_exceeded

Limits

LimitValueDescription
Message size32 KiBThe application bytes of one data frame.
Dial timeout5 sHow long connecting to the guest socket may take before the handshake fails.

Notes

  • A connection ends normally only after both directions have ended.
  • All service connections of one Workspace share a rate limit in each direction. Above it a connection slows down; it is not closed. When one side stops reading, the other side's writes wait for it.
  • The connection has no deadline of its own. Set one in the client when you need it.

See also

On this page