Create a WebSocket API in WSO2 API Manager

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] hello welcome to the screencast websocket streaming apis in ws to api manager i am cenduran ambalavana a senior software engineer at wso websocket is a type of streaming api ssc and websub are the other type of streaming apis in wso2 api manager with streaming apis we have added first class support for even-driven architecture and asynchronous apis virtual ap management capabilities of the wso2 api manager have been added to streaming apis a sync api specification is a standard for defining asynchronous apis similar to open api specification for rest apis we can create a streaming api from an async api definition or export an existing streaming api to an async api definition streaming api types are mainly focused on web-friendly protocols and integration components of wso2 api manager can be used to switch protocols that are other than web sockets ssc and web server this is a high level architecture of a websocket api the gateway contains the websocket api which can talk to either a websocket server directly or an integration component of wso2 api manager such as the wsoq streaming integrator which can switch any protocol to websocket a streaming api is a collection of topics a topic in a streaming api is similar to a resource in a rest api in web sockets this is useful with websocket multiplexing here we use a single server that has multiple channels websocket api topics support url mapping where we can remap parameters from the request as shown here here are some examples of websocket topic url mapping when it comes to the quality of service aspect we can have fine grained authorization at topic level this supports making a topic accessible only to a set of users multiple authentication options are provided for end user applications we have analytics to provide insights about asynchronous communication and rate limiting to control the rate of message flow now let's see a demonstration we'll be looking at a chat service example our website api is going to have three topics that will connect with the websocket servers channels rules is to join a chat room that has the given id notifications is to receive notifications and support is to chat with support we will use the support topic to demonstrate fine-grained authorization at topic level we will be using a web application that will talk to our website api let's go to the api manager publisher click streaming api and select websocket api let's enter the api's details the websocket server endpoint and click on create now let's add the topics after deleting the default topics let's add the notifications topic url mapping of the notifications topic is notifications itself let's add the rooms topic with room id is a path parameter here we are going to use uri bar dot room id to map the path parameter into query parameter finally let's add the support topic next we are going to apply fine grain authorization for the support topic so that this topic is only accessible for those who have a special score for this let's switch on security and click create new score let's create a scope with support subscriber as the display name with an already available role now let's go back to the topics page after switching on security again we can see the created scope under api scores let's choose that click on save and deploy and deploy a revision after that we can publish our websocket streaming api now let's view our api in the dev portal let's go to the subscriptions page and subscribe using the default application let's then click on prop keys and generate an access token we are going to generate it without any scopes for the moment let's copy the generator token and provide it to a web application our web application has connected to the websocket server and we are receiving notifications from the websocket server in real time through the notifications topic let's go ahead and join a couple of rooms here multiple websocket connections are going to be made to the websocket server through the room's topic while all of these are active at the same time we start to see chats in each room as messages are being received through these connections since websocket channels are duplicates we can also send messages through these connections let's send some chats in multiple chat rooms now let's try to connect to the support chat we are not able to do this since our token doesn't have the required score let's go to the dev portal and obtain a new talk this time we are going to generate the token with the support subscriber score let's copy the new token and provide it to our web application now we will be able to join the support chat and interact through the support topic since our latest token was obtained with the required score we hope you enjoyed the screencast stay tuned with wso2 for more content like this thank you
Info
Channel: WSO2
Views: 40
Rating: undefined out of 5
Keywords: Create a WebSocket API, WSO2 API Manager, streaming API, WebSocket protocol, api duplex, api server client, create a WebSocket API from scratch, AsyncAPI definitions, WebSocket backend, api backend development
Id: N4R-qpAB6_I
Channel Id: undefined
Length: 7min 58sec (478 seconds)
Published: Tue Oct 05 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.