Connects to a Suprema BioStar 2 server via WebSocket to stream real-time event logs with optional filtering.
- Connects to BioStar 2 WebSocket endpoint to get BioStar2 device's endpoints in real-time.
- Parses incoming
EventJSON payloads for event log data. - Supports client-side filters:
- Device ID filter – only return events from specified devices.
- Event ID filter – only return events of specific types.
-
Clone this repo and install dependencies:
git clone https://github.com/terryjohndado/WebSocketTest.git cd WebSocketTest npm install -
Update the WebSocket endpoint URL and BioStar2 API endpoint URL.
- Update BioStar2 login credentials.
- Configure filters Here, you can use bsEvent.Event.DeviceId.Id to filter the events by Device ID or bsEvent.Event.EventTypeId.Code to filter the events by Event Code.
※ Explore Event class to check for other filters.

-
Run it:
node index.js
-
The app will:
- Connect over WSS to BioStar 2.
- Authenticate as needed.
- Listen for and parse incoming event logs
- Filter based on
deviceFilterand/oreventFilter. - Emit or log only the matching events.