The Development of Node.JS Server to Communicate With KEPServerEX Via Configuration API

Zeno Chullamonthon
Jun 18 · 5 min read

KEPServerEX is one of the Kepware product that extends the connectivity solutions which support IoT and are ready for the organization and enterprise use. KEPServerEX is one of the OPC servers. To collect field devices data up to the OPC server, KEPServerEX is needed. It supports many channels such as ABB Totalflow, Mitsubishi FX, ODBC Client, Modbus TCP/IP, etc.

Anyone might wonder how we can send these data to other servers or webpages? How we can set up the IoT project with the Modbus protocol? This article has a solution. After reading this article, you will be able to develop a third-party application that uses the RESTful API to communicate with the KEPServerEX.

Whatever data that can be connected to the KEPServerEX, that data can also be sent to your third-party application too. — phakhawatchu

Let’s prepare some of the programs before we start.

  1. KEPServerEX 6.x (Download Demo from here >>
  2. Node.js (Download from here >>

KEPServerEX Configuration:

Firstly, prepare the channel for connecting the field devices. Here I use the Simulation Examples channel which is already prepared by the default.

Figure 1 — The Function controller inside the Simulation Examples channel

Secondly, please make sure that the Configuration API is already setup. If not, please follows the instructions below.

  1. Enable the Configuration API by right-clicking on the Administration icon located in the system tray and select Settings. Then go to Configuration API Service and follow the setup in Figure 2 below.
  2. Click on the “" in the View in browser
  3. A web browser that displays the documentation for the Configuration API will open. Then the setting on Configuration API is finished.
Figure 2 — The Configuration API Service settings
Figure 3 — The Kepware Configuration API REST Interface Documentation page

IoT Gateway for API Setup:

Let’s create a REST Client that will POST the data from KEPServerEX to our application.

1. Click on Add Agent in IoT Gateway. Name it and choose REST Client. Then click on Next as given in Figure 4.

Figure 4 — New Agent Step 1

2. On the URL, please use “” which we will create the server on that URL later. The method is “POST”. Check on “wide-format with a rate of publishing is 1000 ms”. Then click on Next and Finish.

Figure 5 — New Agent Step 2

3. After finish adding Agent, click on the Agent name and choose Add IoT items. Locate the Simulation Examples channel, then click on the Functions controller. You will see the pre-defined tags. Choose any tag you want. Here I will choose the “Sine1” tag and click Apply.

Figure 6 — Adding IoT items

4. This console will show the data rate setting. Here I will set the scan rate at “1000 ms”. And it will publish when there is the data change. So, I choose “Only on Data Changes”. Then click OK.

Figure 7 — Console for data rate setting

5. If you get the error message as describe below, don’t worry. It means that you haven’t set up your application or server yet. Now, you have finished preparing the REST Client.

REST client ‘Agent’ publish failed — reason: ‘Connection refused: connect’.

Node.js Server:

Let’s prepare our first third-party application via Node.js. I will develop the server that can receive the data from KEPServerEX. Please follow my steps below.

1. Create the folder for your Node.js server.

2. Open any command tools, locate to that folder, and run the command.

npm init -y
npm install http

3. Create an index.js inside this folder, then copy and paste the code below.

const http = require('http');const server = http.createServer(function (request, response) {
if (request.method == 'POST') {
var body = '';
request.on('data', function (data) {
body += data;
request.on('end', function () {
var json = JSON.parse(body); //parse to JSON
console.log(json); //the value is printed here
response.writeHead(200, { 'Content-Type': 'text/html' });
response.end('post received');
const port = 3000;
const host = '';
server.listen(port, host);
console.log(`Listening at http://${host}:${port}`);

4. Go to your command tools, then run the command

node index.js

5. After you run it, you might get something like this in the console log in every 1000 ms. You can develop the project more to deal with the JSON data.

timestamp: 1592499751826,
values: [
id: ‘Simulation Examples.Functions.Sine1’,
v: -37.9796486,
q: true,
t: 1592499751457

For instance,

  •” is ‘Simulation Examples.Functions.Sine1’ which is the tag name of the Sine1 tag
  • json.values.v” is -37.9796486 which is the value of the Sine1 tag
Node.js Server result


Now we have finished implementing the Node.js server for receiving the data from KEPServerEX via Configuration API. This RESTful API can be integrated with many programming languages to design your own 3rd-party application such as C#, ASP.NET, Java, etc.

Enjoy your code, Enjoy your life!

The Startup

Medium's largest active publication, followed by +734K people. Follow to join our community.

Zeno Chullamonthon

Written by

Electrical Engineering | Automation Engineering | King Mongkut’s University of Technology Thonburi (KMUTT)

The Startup

Medium's largest active publication, followed by +734K people. Follow to join our community.

Zeno Chullamonthon

Written by

Electrical Engineering | Automation Engineering | King Mongkut’s University of Technology Thonburi (KMUTT)

The Startup

Medium's largest active publication, followed by +734K people. Follow to join our community.

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store