Server Communication Protocols Guide
Server Communication Protocols Guide
Wise SCADA supports various communication protocols for communicating with different systems and applications. The protocol selected on the Servers page determines the communication method and data format through which the project provides services to external systems.
Secure HTTPS versions of HTTP-based protocols and the WebSocket Secure option of the WebSocket protocol can also be used. For secure connections, the HTTPS certificate must be configured.
1. Wise SCADA (Native Protocol)
This protocol is specifically developed for two different Wise SCADA projects to communicate with each other.
- Use Case: Used when a field Wise SCADA (Client) project needs to transfer data to a central Wise SCADA (Server) project.
- Feature: Supports both TCP and UDP communication simultaneously. Data packets are compressed and encrypted, providing maximum performance and security.
- Recommendation: If you are using Wise SCADA software on both ends, you should definitely select this protocol.
2. Modbus
When presenting data to external devices via Modbus, Wise SCADA uses the following standards:
- Addressing Structure: Uses the 6-Digit (e.g., 400001) addressing format.
- Supported Function Codes: 1, 2, 3, 4, 5, 6, 15, 16, 23.
- Address Mapping: The mapping between your tag names within Wise SCADA (e.g., “Tank_Level”) and Modbus addresses (e.g., “40001”) is done via the Tag Synchronization menu. This allows you to manage your Modbus map without changing tag names in your project.
- You can review the Modbus Communication page for more details.
3. WebSocket
It is a real-time communication protocol designed for web and mobile applications.
WebSocket allows a connection to be established once and kept continuously open. The server can send data changes to the client in real time.
WebSocket Secure uses the same communication structure over a secure TLS connection.
- WebSocket: Standard WebSocket connection (ws)
- WebSocket Secure: Encrypted WebSocket connection (wss)
If a secure connection will be used, the HTTPS certificate must be created in Wise SCADA and installed on the required client computers.
For detailed information about certificate creation, client installation, and HTTPS configuration, refer to the HTTPS page.
4. HTTP / HTTPS Communication Options (REST API)
Allows external systems to access Wise SCADA tags using standard HTTP methods.
The following data formats are supported:
- HTTP: JSON
- HTTP: XML
- HTTP: Plaintext
- HTTPS: JSON
- HTTPS: XML
- HTTPS: Plaintext
HTTP and HTTPS options use the same data structure and request methods. The main difference between them is connection security.
With HTTP connections, communication is performed over standard HTTP, while HTTPS options encrypt the communication using TLS.
For example, in the JSON protocol, selecting HTTPS: JSON instead of HTTP: JSON allows the same REST API structure to be used over a secure HTTPS connection.
To use HTTPS protocols, an appropriate certificate must be created in Wise SCADA. The certificate may also need to be installed on client computers so that the connection is recognized as trusted.
For detailed information about certificate creation, client installation, and HTTPS configuration, refer to the HTTPS page.
A. Data Reading (GET Method) Structure
The table below shows the outputs for requests made to the /tags/ endpoint according to formats.
| Format | Single Query Response (/tags/Tag1) | Multi Query Response (/tags/?tags=Tag1,Tag2) |
| JSON | {“tags”:{“Tag1”:false}} | {“tags”:{“Tag1″:false,”Tag2”:false}} |
| XML | <response><tag name=”Tag1″>false</tag></response> | <response><tags><tag name=”Tag1″>false</tag>…</tags></response> |
| Plaintext | false | Tag1: falseTag2: false |
B. Data Writing (PUT Method) Structure
| Format | Request Body | Server Response |
| JSON | {“Tag1”:true, “Tag2”:true} | {“Tag1″:”success”, “Tag2″:”success”} |
| XML | <request><tag name=”Tag1″>true</tag></request> | <response><tag name=”Tag1″>success</tag></response> |
| Plaintext | Tag1: trueTag2: true | Tag1: successTag2: success |
5. Custom: JSON
Provides raw JSON data transfer over a raw TCP socket without the “Header” overhead of the HTTP protocol.
- Biggest Advantage: Both READ and WRITE operations can be performed simultaneously within a single Request packet. This reduces network traffic by 50%.
- Who Should Use It? Embedded systems that do not host an HTTP library or custom C#/.NET applications requiring high performance.
JSON Packet Structure
The Client sends a single JSON object to the server in the following format:
JSON
{
"read": [ "Tank_Level", "Valve_Status" ], // List of tags to be read
"write": [ // Tags and values to be written
{ "tag": "Set_Value", "value": 50 },
{ "tag": "Start_Command", "value": true }
]
}
C# Integration Guide and Code Example
The following C# example connects to the Wise SCADA server and exchanges data via the Custom JSON protocol.
- Requirements: You must add the Newtonsoft.Json (NuGet) library to your project.
C#
using System;
using System.Net.Sockets;
using System.Text;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
public class WiseScadaClient {
public void Communicate() {
// 1. CONNECTION SETTINGS
string serverIp = "127.0.0.1"; // Wise SCADA Server IP Address
int port = 8000; // TCP port in Server settings
int timeout = 1000; // Timeout duration (ms)
using (TcpClient client = new TcpClient()) {
try {
// Start connection
client.SendTimeout = timeout;
client.ReceiveTimeout = timeout;
client.Connect(serverIp, port);
NetworkStream stream = client.GetStream();
// 2. PREPARING THE REQUEST PACKET (BOTH READ AND WRITE)
// Tip: Add what you want to read to the 'read' array,
// and what you want to write to the 'write' array.
var requestObject = new {
read = new[] { "BooleanTag_1", "BooleanTag_2" },
write = new object[] {
new { tag = "BooleanTag_3", value = false },
new { tag = "BooleanTag_4", value = true }
}
};
// 3. SENDING DATA (Serialization)
string jsonRequest = JsonConvert.SerializeObject(requestObject);
byte[] dataToSend = Encoding.UTF8.GetBytes(jsonRequest);
stream.Write(dataToSend, 0, dataToSend.Length);
// 4. LISTENING FOR RESPONSE (Deserialization)
byte[] buffer = new byte[8192];
int bytesRead = stream.Read(buffer, 0, buffer.Length);
if (bytesRead > 0) {
string jsonResponse = Encoding.UTF8.GetString(buffer, 0, bytesRead);
JObject response = JsonConvert.DeserializeObject<JObject>(jsonResponse);
// Print incoming data to console or process it
Console.WriteLine("Response from Server: " + jsonResponse);
}
}
catch (Exception ex) {
Console.WriteLine("Connection Error: " + ex.Message);
}
}
}
}
How the Code Works:
- TcpClient: Connects to the specified IP and Port using the standard .NET socket library.
- Request Object: An Anonymous object is created, populating the read and write fields. This structure is perfectly compatible with the JSON format.
- Serialization: The C# object is converted into a JSON string that the server can understand using the JsonConvert.SerializeObject method.
- Stream: The data is converted to a byte array, written to the wire (stream), and a response from the server is awaited.
