Skip to content

Latest commit

 

History

History
75 lines (64 loc) · 2.21 KB

PROTOCOL.md

File metadata and controls

75 lines (64 loc) · 2.21 KB

Fiber protocol documentation

NOTE: This documents the internal protocol of the local socket fired up on port 6669.

Payloads

Base format

{
  "op": "int",
  "e": "event name, only sent with DISPATCH payloads",
  "d": "actual data"
}

Summary

This table lists all payloads send and received by Fiber. Each payload have more detailed information below.

Payload OP code Action Description
HELLO 0 recv Sent when you're connected
IDENTIFY 1 send Authenticates and identifies the current client
WELCOME 2 recv Sent when you're authenticated and identified
HEARTBEAT 3 send heart...
HEARTBEAT_ACK 4 recv ...beat?
GO_AWAY 5 recv go away. Clients should try reconnect
NO_U_TBH 6 recv You did an oopsie that Fiber didn't liked.
ABOUT_ME 7 send Used to update metadata representing the client
DISPATCH 8 both Used to dispatch events

Hello

{
  "op": 0,
  "d": {
    "heartbeat_interval": "int",
    "worker": "fiber-xxxxxx"
  }
}

Identify

{
  "op": 1,
  "d": {
    "app_name": "Application name, used as main key for querying a client",
    "client_id": "Unique ID used for a *single* connection, used to handle reconnecting",
    "password": "Authentication token configured"
  }
}

Welcome

{
  "op": 1,
  "d": "hi i'm dad"
}

Go away

{
  "op": 7,
  "d": "go away."
}

Connecting

Fiber listens to the port 6669 by default. You can customize it in config/config.exs. The websocket listens to /

Once you're connected to Fiber, you'll get a HELLO payload that'll include heartbeat interval and debug information such as internal worker id. This should be logged on application logs to make searching through logs easy when there is a lot of load on Fiber, as worker id is logged.