A P2P-based IoT solution for your devices is, in general, simpler to develop and manage than the traditional server-based solution. Read along to get the answer of how a direct connection is established, and which communication patterns are supported to enable a high-performing, developer-friendly IoT solution.
The design of a P2P-based IoT solution vs. a server-based IoT solution
To understand the simple infrastructure of a P2P IoT solution, let’s see it in the light of a traditional server-based IoT solution. The server-based application is a central and complex component in your solution architecture in a server-based IoT solution. Your business logic becomes scattered across the three tiers – client, central server, and IoT device. Often, the central server application is not even written as a regular application but consists of, e.g. proprietary rule definitions and configuration data specific for the chosen platform. Sometimes the programming environment for the three systems is different and needs to be balanced by the same team.
With a P2P-based IoT solution, you only have two tiers to worry about: The client application and the IoT device application. The central services are reduced to a mere mediator that sets up the direct connection between client and device. There is no critical server-side business logic, just connection mediation which is all taken care of by the P2P platform. This greatly reduces complexity and allows you to develop applications using the traditional client/server paradigm with the IoT device as the server application.
Two patterns for direct interaction
The Nabto P2P IoT platform supports two different communication patterns for direct interaction between a client and device application: Request/response through Nabto RPC and a socket-like abstraction through Nabto Streaming.
Using these patterns well-known from other programming contexts, developers just need to work with the client application and the device application – the Nabto servers transparently facilitate the communication between the two; the developer does not need to deploy any central code or do any application-specific configuration on the server.
Nabto RPC allows the client application to securely invoke functions on an IoT device directly regardless of its location. For instance, this can be used to activate a smart lock or retrieve sensor readings directly from the target device.
Nabto Streaming allows the developer to communicate directly from the client application to the target device using a familiar TCP-like data stream abstraction. Nabto Tunnels further abstract this to simplify integration even more – without writing more than a few lines of code. A Nabto TCP Tunnel can be transparently injected as a proxy between an existing TCP client and an existing TCP server on the target device.
Nabto provides a turnkey, battle-tested, P2P IoT solution with state-of-the-art security and high performance. If you want to know more, you can read our P2P explainer or set up a free consultation so we can help you find the best solution for your IoT product(s). Alternatively, you could jump right into exploring the developer friendliness of P2P IoT by creating a free developer account (no credit card required) on the Nabto Cloud Console.