Peerix v0.4 Released
We are thrilled to announce the v0.4 release of the Peerix library. Peerix continues its mission of simplifying WebRTC development by abstracting the heavy lifting of signaling and connection management into a minimal, transport-agnostic API. This release focuses on expanding our signaling transport options for production environments, refining our API for a better developer experience, and optimizing performance under the hood.
Highlights: New Signaling Drivers for Production Scale
While our earlier releases focused on getting peers connected, v0.4 is about moving from local prototypes to distributed production environments. We’ve added two major signaling drivers to support industry-standard messaging infrastructure.
MQTT Driver
The MqttDriver enables signaling via the MQTT protocol and is specifically designed for MQTT over WebSockets. This allows developers to leverage robust brokers like Mosquitto for their signaling needs. It is an ideal choice for lightweight pub/sub signaling within existing messaging ecosystems.
- Requires the external
mqttmodule. - Requires a running MQTT broker, for example, a Mosquitto server.
- Documentation: MQTT Driver
Centrifuge Driver
The CentrifugeDriver integrates with the Centrifugo real-time messaging server. This driver is built for developers who need high fan-out capabilities and reliable reconnection support in high-traffic production environments.
- Requires the external
centrifugemodule. - Requires a running Centrifugo server.
- Documentation: Centrifuge Driver
SSE Driver Enhancements
The SseDriver has been updated to default to the Mercure-compatible endpoint (/.well-known/mercure), making it easier for developers using the Mercure hub to get started without additional configuration. This change simplifies setup and reduces friction for those leveraging Mercure for their signaling needs.
- No external modules required.
- Requires a running Mercure server or another SSE-compatible server (with a code example provided).
- Documentation: SSE Driver
Improved Developer Experience: Local Testing with Docker
To lower the barrier for local development, v0.4 now includes example code snippets and configurations for running signaling backends locally using Docker. You can now quickly spin up instances of NATS, Mercure, Mosquitto, and Centrifugo with standardized setups. This ensures that your local testing environment mirrors your production infrastructure as closely as possible.
API Refinements
In our ongoing effort to create a more intuitive and consistent API, we have made some key changes to method naming conventions. The term publish has been reserved exclusively for the Signaling Layer to align with standard messaging terminology. For the Application Layer, we have introduced share and unshare to better describe how media and data streams are managed. This change helps avoid confusion between signaling events and application-level actions.
Migration Mapping
| Old Method | New Method | Layer |
|---|---|---|
Driver.dispatch | Driver.publish | Driver |
Peer.publish | Peer.share | Peer (media streams) |
Peer.unpublish | Peer.unshare | Peer (media streams) |
Performance and Technical Optimizations
As a core maintainer, my focus is often on the “under-the-hood” efficiencies that keep your apps performant. This release includes several technical wins for reducing message overhead:
- Protobuf-like Format: We have transitioned from a custom binary format to a Protobuf-like format for signaling messages. This transition allows us to use an industry-standard serialization method and reuse it across several internal components, reducing the need for custom parsing logic and minimizing message sizes.
- ICE Candidate Debouncing: To minimize signaling chatter, we’ve introduced the
iceCandidateDebounceoption in the Peer class. It defaults to50ms, batching candidates to reduce the frequency of messages sent during the negotiation phase. - SocketIoDriver Enhancements: We have added an
ackTimeoutoption to the SocketIoDriver, giving you granular control over how long the client waits for server acknowledgments. - Simplified Event Naming: Most drivers now use peer or room identifiers directly as event names. By avoiding string concatenation, we’ve shortened name lengths to reduce signaling overhead.
Upgrade and Migration Notes
If you are moving from v0.3 to v0.4, please review these breaking changes:
- Method Renaming: All application-level calls to
publishandunpublishmust be updated toshareandunshare. This change applies to both thePeerandRemotePeerclasses. - Driver Active State: The Driver class now initializes with the
activeaccessor set tofalseby default. Ensure your logic accounts for the driver state during startup. - Prefix Handling & Separators: Some drivers now use empty prefixes by default and no longer automatically include separators. If you require a separator, it must be part of your prefix string.
- Example: If your prefix is
peerixand the event isevent, it will result inpeerixevent. To getpeerix:event, you must define the prefix aspeerix:.
- Example: If your prefix is
- Namespace Hashing Compatibility: When namespaceHashing is disabled, the room property is now automatically escaped. This prevents character compatibility issues with certain signaling backends that do not support specific symbols or spaces.
Conclusion
This release brings us closer to a truly plug-and-play WebRTC experience that scales. For full details on these changes, please visit our updated resources:
- ๐ Documentation
- ๐ API Reference
