โ† Back to Index ๐Ÿ” Login

startWSLogRelayd

[ ] Denna sida รคr inte markerad som klar

Realtime websocket log and diagnostics relay server.

Declaration

function startWSLogRelayd()

Long Description

Protocol spec may be incomplete, no "Identified as..." for ex.
Works as a central node, accepting senders and listeners. Relaying senders' messages to listeners.

Several senders can send diagnostics to several listeners. Made to simplify debugging by allowing for a unified interface for all diagnostics and allowing for the listening interface to conveniently present extensive detail if desired.

startWSLogRelayd allows for brief as well as extensive diagnostics to be sent. For example, PHP's debug trace can be added in the data field.

The client sends a JSON object to startWSLogRelayd, being the data to be broadcasted to all listeners. For each message, the server is willing to let trough message, categories, data. These are added to a JSON object which is stringified. Several stringified JSON objects can be added together in the same payload, given they are separated by \n. Thus, the serialized/stringified JSON must not contain literal newlines but must have them escaped.

Primitive

Internal

Node JS

External

A set of clients exist to connect to startWSLogRelayd.

Not documented in this database:

Other:

These names may not apply yet.

Configure

System

Preferably with systemd service file.

Node dependencies are kept in startWSLogRelayd's local dir.

Security

Runs on unencrypted websocket, but because it is meant to run behind Nginx reverse proxy, the connection stays secure. This given that Nginx is set to do HTTPS, and thus uses the same encryption layer for websockets, whereas the client access startWSLogRelayd by wss://.

User

The user needs to connect by wss://.... That's all.

There are no particular user configurations.

Execute

Initialize

Operate

Communication is done according to protocol in appendix A.

Finalize

Data

State

Keeps a list of the X latest messages which are forwarded to once the client has connected and identified as listener.

Artifact

Appendix A

Connection

Identification

Sender

{
  "role": "sender",
  "token": "your-secret-token",
  "name": "optionalName"
}

Listener

{
  "role": "listener"
}

Server Responses

On success:

{ "type": "status", "message": "...", "id": <clientId> }

On error:

{ "type": "error", "message": "..." }

Sender โ†’ Server

{
  "message": "Text content",
  "category": "optionalCategory",
  "data": { "optional": "payload" }
}

Server โ†’ Listeners

Message Broadcast

{
  "type": "message",
  "from": "senderName",
  "data": {
    "timestamp": "...",
    "message": "...",
    "senderId": <id>,
    "category": "...",
    "data": { ... }
  }
}

Meta Event (join/leave)

{
  "type": "meta",
  "event": "connected" | "disconnected",
  "id": <clientId>,
  "name": "clientName",
  "role": "sender" | "listener",
  "timestamp": "..."
}

History (on listener connect)

{
  "type": "history",
  "messages": [ ...lastMessages ]
}

Ping/Pong

Metadata

UUID 01982303-1f32-7375-bf44-53dc1029ed71
Project Dev stack: Diagnostics
Language js
File Path ./WSLogRelayd.js
Scope
Modifiers
Created 2025-07-19 14:08:51
Modified 2025-07-20 10:07:04