Server Communication Protocols Guide

Server Communication Protocols Guide

Wise SCADA supports various communication protocols to communicate with other Wise SCADA projects and third-party systems. The protocol selected on the Servers page determines which communication method and data format the server will use to serve the Clients.

For TLS-protected communication, the Wise SCADA Secure, WebSocket Secure, and HTTPS options can be used. Before using these protocols, a server certificate must be configured, and it must be ensured that Clients recognize this certificate as trusted.

For steps on generating a certificate and installing it on a Client computer, please refer to the HTTPS page.

1. Wise SCADA (Native Protocol)

The Wise SCADA protocol is a native communication protocol developed to provide data exchange between two Wise SCADA projects. The Client project can read the tag values that the Server project has made accessible, and if write permission is granted, it can write values to these tags.

  • The Wise SCADA protocol must be selected on the server project’s Servers page and the client project’s Clients page. The protocol supports TCP and UDP communication. The TCP or UDP port defined on the server must be used in accordance with the communication type selected on the client.
  • To communicate between two Wise SCADA projects, Wise SCADA or Wise SCADA Secure can be used. When a TLS-protected connection is required, Wise SCADA Secure should be selected.

2. Wise SCADA Secure (TLS)

Wise SCADA Secure performs communication between two Wise SCADA projects over a TLS-encrypted connection. It protects the confidentiality and integrity of the transferred data. It is especially preferred for projects communicating over the internet or shared networks.

Certificate Requirements A certificate must be generated on the server computer before a connection is established. The IP address or hostname used by the client for the connection must match one of the addresses defined in the server certificate.

If connecting from another computer, the WiseSCADA.cer file located in the server project’s Certificate folder must be installed in the Trusted Root Certification Authorities store of the client computer.

Important: Since the WiseSCADA.pfx file contains private key information, it must not be distributed to client computers. The WiseSCADA.cer file must be used for client installation.

For steps on generating a certificate and installing it on a client computer, please refer to the Certificate Generation and Certificate Installation sections on the HTTPS page.

Comparison of Wise SCADA and Wise SCADA Secure

FeatureWise SCADAWise SCADA Secure
Purpose of useData exchange between two Wise SCADA projectsTLS-protected data exchange between two Wise SCADA projects
Communication protectionProtocol-specific encryptionTLS connection encryption
Certificate requirementNot requiredRequires a server certificate and establishing trust in the certificate on the client
Protocol selectionWise SCADA on both sidesWise SCADA Secure on both sides

3. 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.

4. 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.

5. 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.

FormatSingle 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>
PlaintextfalseTag1: falseTag2: false
B. Data Writing (PUT Method) Structure
FormatRequest BodyServer 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>
PlaintextTag1: trueTag2: trueTag1: successTag2: success

6. 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:

  1. TcpClient: Connects to the specified IP and Port using the standard .NET socket library.
  2. Request Object: An Anonymous object is created, populating the read and write fields. This structure is perfectly compatible with the JSON format.
  3. Serialization: The C# object is converted into a JSON string that the server can understand using the JsonConvert.SerializeObject method.
  4. Stream: The data is converted to a byte array, written to the wire (stream), and a response from the server is awaited.

Leave a Reply