Logo
  • Products
    • SecOps Studio
  • Solutions
    • Pega Stack Shifter
  • Services
    • Pega Enablement
    • Pega Modernization
  • About
  • Contact
  • Blog
Code Vault

Notifications in Pega – Part 1 – WebSocket introduction

December 10, 2024 Code Vault Curators

In this blog article, we will start with some basics about WebSocket technology.

First, let’s talk about the Client-Server model

You can see the client-server model in every service provider architecture. There can be one or more servers serving one or more clients.

When we see from Pega perspective, the application server or the web server is the SERVER and the browser through which we log in Pega application is the CLIENT. There can be multiple clients (multiple operators) accessing the server (Pega application).

Now all these data are requested by the client. When we log in from the browser, HTTP requests are sent and the HTML content from the server is sent as web pages to the client.

So, everything you see is ask and give. The client asks the server and the server provides the server with the necessary data.

As a client, do we need to ask for data every time from the server? Think of use cases like real-time data – Tracking cab, packages, newsfeed or gaming, and chat applications. Can the server be proactive and send the data to the clients? Yes, they can. WebSocket CAN be a solution 😉

Let’s talk about some basic differences between HTTP and WebSocket

What are the main differences between HTTP and WebSocket?

WebSocket is not a replacement for HTTP but is an extension.

HTTP are usually half-duplex communication, whereas WebSocket supports full-duplex communication.

What is half-duplex and full-duplex communication?

Half-duplex – It means, the server does not push any data. You need to request the server for any data.

Think of a chat application, let’s see in the picture how it would behave if it used half-duplex and full-duplex communication.

WebSocket provides high performance and low-latency communication than HTTP, How?

For WebSocket, the connection is opened once with a handshake is kept open for server-client communication and can be close any time. So, latency is very low, server can just keep pushing data. Whereas in HTTP, you need to form an HTTP request (heavy) every time for the communication.

WebSocket uses the schema ws:// similar to http:// or https://

What ports does WebSocket use?

WebSocket is designed to work over the default HTTP ports – 80 and 443 (for TLS connections). In this way, you don’t need to take special care on WebSocket connections like firewall blocking connections etc.

Okay, Now let’s go one step deep into WebSocket technology 😊

What is WebSocket?

– WebSocket is a bidirectional full-duplex protocol, used in client-server communication similar to HTTP protocol.

– It is a stateful protocol – which Means, the connection between server and client will be kept alive until it is terminated manually but either the client or server. The connection is a single TCP connection.

– It is mostly used in real-time data applications, gaming and chat applications.

The steps in establishing the WebSocket connection is as follows

Step 1: The process begins with sending a normal HTTP request to the server.

The header contains the request for a WebSocket connection.

Step 2: The server responds with a handshake by establishing the connection.

Step 3: Once the connection is established, then messages can be pushed into the connection.

WebSocket works with API events. The following events are used

Open – Once the connection is established, an event onopen is fired, to say that the connection is open

Message – This event happens when the server wants to send some data. – onmessage event

Close – This event onclose marks the end of connection between server and client

Error – When some error occurs – onerror is raised followd by close event.

JavaScript applications use the WebSocket technology effectively for server-client communication.

Enough of theory, let’s see practically how the WebSocket connection is established.

Important note: Pega started supporting WebSocket connections from Pega 7.3. In prior versions long-polling is used for these message communications.

How to check if Pega uses a WebSocket connection?

Step 1: Launch the designer studio in Chrome browser.

Step 2: Go to browser developer tools and click on the networks tab – WS

Step 3: Now just refresh the browser and see the magic 😊

You see an websocket open connection established.

Step 4: Click on the name, to check more content

Headers tab – You see, it uses the PRPushServlet to establish the WebSocket connection.

You will see the servlet configuration in the web.xml

Status code – green

Click on the Messages tab.

You will see some messages. These are corresponding to heartbeat checks (default). Green signifies the messages sent to the server (upload) and red is the message from the server to the client (download)

This will keep on going every 10 seconds.

Initiator tab

Here you will the Java script files responsible for initiating the WebSocket connection.

So, what we understood is

Whenever you log into the Pega application, the WebSocket connection is established by default. You are all ready to send and receive messages using WebSocket.

Hope you understood some basics about WebSocket and its usage in Pega.

In the next article, we will see how we can push messages (notifications) to the Pega browser clients using WebSocket 🙂

Notifications in Pega – Part 2 – Web Gadget channel

 

  • process
Code Vault Curators

A technical team dedicated to empowering the Pega ecosystem with in-depth knowledge, guided by Premkumar Ganesan's vision.

Post navigation

Previous
Next

Pega Courses

Pega courses can be accessed at https://myknowacademy.com

Search through the blog

Tags

activity authentication background-processing case-management data-model declarative-processing email-processing file-processing pega-core-concepts pega-integration process reporting security system-administration user-interface validation

Categories

  • Code Vault

Recent posts

  • Service REST – Usage and Configurations in Pega
  • Queue processor – Usage and Configurations
  • Data Pages Usage & Configurations in Pega
  • Requestor types in Pega
  • Case Locking Mechanism in Pega

Related Articles

Code Vault

Flow Action – Usage and Configurations in Pega

December 10, 2024 Code Vault Curators

In this blog article, we will see about different configurations and usage of a flow action rule. What is flow action rule? Flow action rule contains all the configuration points that describe how a user interacts with an assignment using work forms. We know that every business process follows a certain flow. The flow starts […]

Code Vault

Notifications in Pega – Part 4 – Read published message

December 10, 2024 Code Vault Curators

In this blog article, we will see how Pega Subscribers can read the published event messages This is the continuation of the previous article, where we published a custom notification message as soon as the case is assigned to the Sales Work basket. Please go through the article series in order number for better understanding. […]

Code Vault

Notifications in Pega – Part 3 – Create custom notification

December 10, 2024 Code Vault Curators

In this blog article, we will see how to create a custom notification and perform UI action using WebSocket Publish-Subscribe event processing. It is recommended to go through the first two articles on the notification series before proceeding on this article. https://myknowtech.com/tag/notification Business scenario: Whenever a work is assigned to Sales workbasket, the workbasket should […]

Code Vault

Service Level Agreements in Pega

December 10, 2024 Code Vault Curators

In this blog article, we will see in detail about Service level agreements. The main objective of Service Level Agreement is to process any time bound requirements in the Pega application. Imagine, Timesheet Pega application. Reminder email – If an employee fails to submit the timesheet by the end of the month (April 30th), then […]

About

MyKnowTech was born with a mission to bridge the gap between technical expertise and business needs. We are a boutique firm specializing in Pega solutions, delivering them with a personal touch. At the heart of our philosophy is a commitment to putting clients first.

Company
  • About
  • Leadership
  • Career
  • Contact
Resources
  • Blog
  • Services
  • Solutions
  • Insights

©  MyKnowTech B.V. All Rights Reserved.

  • Sitemap
  • Terms & Conditions
  • Privacy Policy