This is IronFlock's fork of gammazero/nexus. It is the library underneath
the IronFlock WAMP router. The module path is github.com/ironflock/nexus/v3. Everything else in this README
applies to both repositories unless it says otherwise.
What the fork adds on top of upstream:
- Extension seams for a clustered router.
BrokerandDealerare interfaces.RealmConfig.BrokerFactoryandDealerFactorylet you wrap the defaults (NewDefaultBroker,NewDefaultDealer). Subscription and registration observers, aSubMetaSinkfor subscription meta events, andDealer.EvictRegistrationlet an external layer mirror and forward routing state between nodes. - Operations API.
Router.Drain()sends GOODBYE to every client and refuses new sessions, while work already in flight completes.Router.KillSessionsByAuthidandKillSessionsByAuthroleclose sessions from Go code. - Router options.
RealmConfig.AuthorizeUnlockedlets a slowAuthorizerrun without stalling the realm.RealmConfig.StrictRequestIDsenforces sequential request IDs (WAMP §5.1.2). Websocket servers expose TCP buffer and Nagle settings. Authenticators can see the target realm URI. - Protocol features.
force_reregisterandwamp.session.list_testaments. - Robustness fixes. Slow callers no longer block callees. Websocket frame writes have a deadline. Nothing is
sent on a session after its GOODBYE, and
Close()flushes queued frames up to the GOODBYE. Realm shutdown runs in order. PeerCloseis idempotent. Several goroutine leaks are fixed. Progressive payload transport (PPT) round-trips over every serializer. - WAMP conformance harness.
spec/has YAML test plans that check the router's behaviour frame by frame over the wire.
Fixes that are useful outside IronFlock are offered back to gammazero/nexus as pull requests. IronFlock-specific code stays out of this repository.
nexus is a WAMP v2 router library, client library, and a router service, that implements most of the features defined in the WAMP-protocol advanced profile. The nexus project is written in Go and designed for highly concurrent asynchronous I/O. The nexus router provides extended functionality. The router and client interoperate with other WAMP implementations.
See the upstream nexus project Wiki for documentation, examples, and operational details. The wiki does not cover the fork-only additions listed above. Those are documented in the Go doc comments.
The Web Application Messaging Protocol (WAMP) is an open standard WebSocket subprotocol that provides two application messaging patterns in one unified protocol: Remote Procedure Calls and Publish & Subscribe. WAMP is also referred to as WAMP-proto it distinguish it from [other uses](https://en.wikipedia.org/wiki/WAMP_(disambiguation) of the acronym.
Using WAMP you can build distributed systems out of application components which are loosely coupled and communicate in (soft) real-time.
Nexus is a software package that provides a WAMP router library, client library, and stand-alone WAMP router service. This nexus package provides a messaging system for building distributed applications and services. Endpoints using websockets, TCP sockets, Unix sockets, and in-process connections may all communicate with each other via pub/sub and routed RPC messaging.
- The router library can be used to build custom WAMP routers or to embed a WAMP router in an application.
- The client library can be used to build clients that connect to any WAMP server, or to communicate in-process with a WAMP router embedded in the same application.
- The router service can be run as-is to provide WAMP routing.
go install github.com/ironflock/nexus/v3/nexusd@latest
Run nexusd -help to see usage information. You can run nexusd with command-line flags only, but the
configuration file gives you more options.
git clone https://github.com/IronFlock/nexus.git
cp nexus/nexusd/etc/nexus.json ./
vi nexus.json
nexusd -c nexus.json
git clone https://github.com/IronFlock/nexus.git
cd nexus/examples
Use the nexus router library to build a WAMP router or to embed one in your service. Use the nexus client library to build WAMP clients into your Go applications. Import the v3 packages of the fork's module path. v3 is the only supported version.
import (
"github.com/ironflock/nexus/v3/client"
"github.com/ironflock/nexus/v3/wamp"
)This fork does not publish a container image. The ghcr.io/gammazero/nexusd image is built from upstream code
and does not include the fork's changes. Build the image from this repository instead. The
Dockerfile installs nexusd from the github.com/ironflock/nexus/v3 module:
docker build -t nexusd .
docker run -p 8080:8080 nexusd
By default, the router accepts connections on port 8080 and allows anonymous clients on realm1. To change
these values or get help, pass options to the container process:
docker run nexusd --ws 0.0.0.0:8888 --realm autobahn
docker run nexusd --help
You can also mount a nexusd configuration file into the container for more control and a more secure setup. See the nexusd configuration reference for details. You can also run the container process as an unprivileged user.
The examples show how to create simple clients and servers. Start with examples/README.md. The upstream wiki documentation has more examples of advanced profile features.
The interop examples show nexus working with other WAMP implementations. Each one has its own README.md that explains how to set up the environment and run it.
The nexusd service is also an example of a stand-alone WAMP router. Its configuration file sets every
router option. Use the file in nexusd/etc/ as a starting point for your own WAMP router service.
Read the Contributing guide if you want to contribute.
Report problems with the fork-only additions as an issue on this fork. Report general nexus problems and feature requests upstream.
- Concurrent Asynchronous I/O Nexus supports large numbers of clients concurrently sending and receiving messages, and never blocks on I/O, even if a client becomes unresponsive. See Router Concurrency and Client Concurrency for details.
- WAMP Advanced Profile Features This project implements most of the advanced profile features in WAMP v2. See current feature support provided by nexus. Nexus also offers extended functionality for retrieving session information and for message filtering, giving clients more ability to decide where to send messages.
- Flexibility Multiple transports and serialization options are supported, and more are being developed to maximize interoperability. Currently, nexus provides websocket, rawsocket (tcp and unix), and local (in-process) transports. JSON, MessagePack, and CBOR serialization is available over websockets and rawsockets.
- Security TLS is available over websockets and rawsockets with client and server APIs that allow configuration of TLS. The nexus router library also provides interfaces for integration of client authentication and authorization logic.
The currently maintained version of this module is 3.x. Earlier major versions are no longer supported.
| Feature | Supported |
|---|---|
| progressive_call_results | Yes |
| progressive_call_invocations | Yes |
| call_timeout | Yes |
| call_canceling | Yes |
| caller_identification | Yes |
| call_trustlevels | No |
| registration_meta_events | Yes |
| registration_meta_procedures | Yes |
| pattern_based_registration | Yes |
| shared_registration | Yes |
| force_reregister | Yes |
| sharded_registration | No |
| registration_revocation | No 1 |
| procedure_reflection | No |
| payload_passthru_mode | Yes |
| Feature | Supported |
|---|---|
| subscriber_blackwhite_listing | Yes |
| publisher_exclusion | Yes |
| publisher_identification | Yes |
| publication_trustlevels | No |
| subscription_meta_events | Yes |
| subscription_meta_procedures | Yes |
| pattern_based_subscription | Yes |
| sharded_subscription | No |
| event_history | Yes |
| topic_reflection | No |
| payload_passthru_mode | Yes |
| Feature | Supported |
|---|---|
| rawsocket (TCP & Unix) transport | Yes |
| session meta events | Yes |
| session meta procedures | Yes |
| testament meta API | Yes |
| TLS for websockets | Yes |
| TLS for rawsockets | Yes |
| challenge-response authentication | Yes |
| cryptosign authentication | Yes 2 |
| cookie authentication | Yes |
| ticket authentication | Yes |
| batched WS transport | No |
| longpoll transport | No |
| websocket compression | Yes |
Nexus provides extended functionality around subscriber black/white listing and in the information available via the session meta API. This enhances the ability of clients to make decisions about message recipients.
Footnotes
-
The router sends an unsolicited
UNREGISTEREDonly when it evicts an old registration because a client registered the same procedure withforce_reregister. There is no API to revoke a registration, and the feature is not announced inWELCOME. ↩ -
Router side only (
auth.NewCryptoSignAuthenticator). The nexus client does not implement cryptosign. ↩
