Using SAP PCo WebSocket in any application without using SSCE
As SSCE is available in 15.x version of MII and there could be a need to subscribe tags using WebSocket in previous version as well, below blog would help you do it with any version of MII and for that matter without MII as well. You just need SAP Plant Connectivity (PCo) version that provides web socket server.
SAP Plant Connectivity provides a feature that allows users to use SAP PCo’s WebSocket server from any application using standard WebSocket object available in JS. As there is no document mentioning step by step configuration details, below blog would help you quickly configure PCo and subscribe to tags from an application.
The steps are:
- Configuring a Source system.
I selected OPC UA source system and provided requisite details viz. Server End point and credentials. You can use any source system type which supports WebSocket.
Figure 1 Add Source System
Figure 2 Add credentials to source system
I have used username/password authentication but you have a choice to select authentication mode as per your preference.
Test the connection, it should be connected successfully.
- Create agent using above created source system.
- Go to server tab of agent configuration screen and select WebSocket Server.
Figure 3 Select Server Type
- Provide an available TCP/IP port.
- In Maintain Destination System for WebSocket section, click on Create Destination System. This would create a destination system for WebSocket so that you can subscribe to it.
Figure 4 Create Destination System
- Go to Subscription Items Tab and click on browse button given at bottom left. Select the tags your want to subscribe and hit Ok.
Note: If you are just using WebSocket, then you need not add subscription items as you would be sending Tag Name from the web application. It is required only when you are using Static Notifications.
Figure 5 Add Subscription Items
- Create a notification using this agent.
- Select the type of notification as “Notification Template for Remote Subscription”.
Figure 6 Create Template Notification
- Provide name and description.
- Go to Destinations tab of notification and click on add destination system. Following option would be available as “Destination System for WebSocket”.
Figure 7 Add Destination for Template Notification
Provide name and description (optional) and click on Ok. Destination system should be added as shown below.
Figure 8 Destination Selection
- Start the agent. It should show message as “Agent started Successfully.”
Figure 9 Agent Started Successfully
- Configuration from SAP PCo side is complete.
- Now you can subscribe to web socket using : ‘ws://<server>:<WebServer Port configured in PCo>/<DestinationName configured in notification template>’
- Input/message to WebSocket should be as shown below. Please refer to PCo help document “JSON Messages for WebSocket Connections” for further details of messages and structures.
“Template”: “<Notification Template Name>”,
“Name”: “<TagGroup> /<TagName1>”,
“Name”: “<TagGroup> /<TagName2>”,
- Please note, the delimiter between TagGroup and TagName in message should be “/” and not “.”.
- With this, you should be able to make use of WebSocket() object and subscribe to your tags using PCo WebSocket server.
thanks Swaroop Anasane for your nice blog
Could you give more details on step 6, where to subscribe, please give an example with connection to an Application