Realtime websocket log and diagnostics relay server.
function startWSLogRelayd()
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.
Node JS
A set of clients exist to connect to startWSLogRelayd.
Not documented in this database:
Other:
wscat
Preferably with systemd service file.
Node dependencies are kept in startWSLogRelayd's local dir.
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://
.
The user needs to connect by wss://...
. That's all.
There are no particular user configurations.
Communication is done according to protocol in appendix A.
Keeps a list of the X latest messages which are forwarded to once the client has connected and identified as listener.
wws://<host>:<port>
{
"role": "sender",
"token": "your-secret-token",
"name": "optionalName"
}
{
"role": "listener"
}
{ "type": "status", "message": "...", "id": <clientId> }
{ "type": "error", "message": "..." }
{
"message": "Text content",
"category": "optionalCategory",
"data": { "optional": "payload" }
}
{
"type": "message",
"from": "senderName",
"data": {
"timestamp": "...",
"message": "...",
"senderId": <id>,
"category": "...",
"data": { ... }
}
}
{
"type": "meta",
"event": "connected" | "disconnected",
"id": <clientId>,
"name": "clientName",
"role": "sender" | "listener",
"timestamp": "..."
}
{
"type": "history",
"messages": [ ...lastMessages ]
}
"ping"
"pong"
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 |