Skip to content

0xspeedybird/livepeer-hackathon-streamr-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

Streamr WebSocket Bridge

This project exposes a lightweight WebSocket bridge that receives raw JSON payloads and republishes them to a configured Streamr stream. It is designed to run alongside a producer process that pushes telemetry or metrics over a local WebSocket connection.

Prerequisites

  • Node.js 18+ (Node 20 recommended) and npm, or Docker 24+ with Docker Compose.
  • A Streamr private key with publish permissions to your target stream.

Configuration

  1. Copy the sample environment file:
    cp client/.env.sample client/.env
  2. Edit client/.env and provide either:
    • STREAMR_ETH_ACCOUNT and STREAM_ID, which will be combined as <account>/<stream>; or
    • STREAMR_STREAM_ID with the full stream identifier.
  3. Optional configuration:
    • WEBSOCKET_PORT (default 8080) controls the inbound WebSocket listener.
    • LOG_LEVEL (default info) controls the pino logger verbosity.

Local Development

cd client
npm install
npm start

The bridge listens on ws://localhost:8080 by default. Connect with any WebSocket client and send JSON payloads; successful publishes return {"status":"ok"}. Invalid JSON or publish failures respond with an error message and are logged.

Running with Docker Compose

docker compose build
WEBSOCKET_PORT=8080 docker compose up

Compose reads environment values from client/.env for Streamr credentials. Export or set WEBSOCKET_PORT before docker compose up if you need a non-default port. The container maps the chosen port on both the host and container.

Testing

Unit tests cover the message handling logic that validates payloads, publishes to Streamr, and returns acknowledgements.

cd client
npm test

Logging

Logs are emitted through pino and include connection identifiers, client addresses, and error details to make traceability straightforward in production environments.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published