Introduction to WitRPC
What is WitRPC?
OutWit.Communication (WitRPC) is a high-performance, full-duplex, and highly configurable remote procedure call (RPC) framework for modern .NET environments. Its primary purpose is to simplify communication between components of a distributed system. These components might be separate processes on the same machine (using inter-process communication, or IPC), services communicating over a local network, or applications interacting across the internet.
WitRPC provides a unified programming model that lets developers define communication contracts using standard C# interfaces. The framework handles the complex mechanics of data serialization, transport, security, and error handling. By abstracting these low-level details, WitRPC enables developers to focus on their application's business logic rather than network programming.
The framework is built with modularity and extensibility in mind. Developers can choose from various transport mechanisms, serialization formats, and security configurations to tailor the communication stack to the specific needs of their application, whether that means prioritizing raw performance for local IPC or ensuring robust security for web-based clients.
The Core Philosophy: A Modern WCF
WitRPC's design and architecture are heavily influenced by Windows Communication Foundation (WCF). The framework was conceived to fill a gap that emerged as developers moved from the .NET Framework to the newer, cross-platform .NET Core (now simply .NET). WCF was a cornerstone of distributed application development in the .NET Framework, but its absence in .NET Core left a void for developers who appreciated its programming model.
One of the most significant concepts WitRPC inherits from WCF is the service contract. In WCF, a service's operations were defined by creating a C# interface and annotating it with the [ServiceContract] attribute. This interface-driven approach provided strong typing, compile-time checking, and excellent IDE support because a client-side proxy could be automatically generated from the interface.
By contrast, frameworks like SignalR or certain uses of gRPC invoke remote methods by name (as plain text strings). This approach lacks compile-time safety, making it error-prone and difficult to refactor.
WitRPC was created to bring WCF's robust, interface-driven development experience to modern .NET. The framework is built on the idea that a shared C# interface serves as the single source of truth for communication between client and server. The client obtains a proxy object that implements this interface, and calls to the proxy's methods are transparently translated into remote procedure calls. This design is fundamental to WitRPC: it is not just another RPC library but a framework that prioritizes developer productivity, type safety, and maintainability, much like its spiritual predecessor, WCF.
Key Features at a Glance
WitRPC offers a comprehensive set of features to address a wide range of communication needs in distributed systems:
-
Interface-Driven Contracts: WitRPC uses standard C# interfaces to define service contracts. All communication is strongly typed, providing compile-time safety and making code easier to understand, refactor, and maintain.
-
Pluggable Transports: The framework supports multiple transport mechanisms, allowing you to select the optimal channel for each scenario. Options include high-speed local IPC (such as Named Pipes and Memory-Mapped Files) as well as network transports like TCP, secure TCP (TLS), and WebSockets.
-
Pluggable Serializers: You can choose from several popular serialization libraries to encode data for transmission. Options include JSON (for readability and interoperability), MessagePack, MemoryPack, and ProtoBuf (for high performance and compact payloads).
-
Built-in Security: WitRPC provides a robust security model out of the box. It features an automatic RSA/AES encryption handshake to protect data in transit, and a flexible token-based authorization system to control access to services.
-
Full-Duplex Communication: The framework natively supports bidirectional communication. Servers can invoke methods or raise events on connected clients, enabling real-time, event-driven architectures where the server can push updates to clients without waiting for a request.
-
Dynamic Service Discovery: WitRPC includes a service discovery mechanism that allows clients to dynamically find and connect to available services on a network without hardcoded addresses or ports. This is particularly useful in microservice architectures or environments with dynamic service deployment.
-
Dedicated IPC Host/Agent Model: For complex inter-process communication scenarios, the OutWit.InterProcess extension provides a specialized host/agent model for managing child processes. This includes launching, monitoring, and cleanly shutting down agent processes to ensure a robust and reliable IPC architecture.