Realtime updates and websockets in Wappler?

Hi

Just finding my way around the use of something like Pusher Websockets to enable real time user actions and polling without having to refresh the data with something like scheduler. I am no expert and really just trying to work out which way is up and down, but I have an app I am building which requires a heartbeat to check for updates to ensure all users interfaces are synchronized. Also to enable instant massaging / live chat with multiple users.

Is there any plans to integrate this kind of webscocket service into Wappler, or should I be looking outside of Wappler and maybe an API integration?

Thanks!

it is on road :blush:

Maybe this will work in the mean time? PREVIEW: Scheduling Actions with NodeJS - Request For Comments - Wappler Community

Sending real-time results to the user in database operations will take the system too busy. In addition, the cron task always runs, so it will run even if there is no user in the system.

may not be a good option.

2 Likes

Yep you are right, plus it’s running “blind” it would require to much server resource and scheduling isn’t really designed for this.

1 Like

Can somebody explain what is the main difference between scheduling actions like every 1 sec. and polling/socket.io?

I understand from this thread that scheduling will run even if no user is active, whereas polling runs only when user is active, therefore polling is more efficient. Is there any other difference?

Chat, gaming, and real-time web applications constantly exchange data. The server only responds according to the requests from the client. The client reaches the change in the server with a new request. A new request causes the rules in the HTTP protocol to be repeated and the use of excessive traffic. Websocket is used because it is costly and difficult to manage real-time applications with traffic and HTTP protocol.

2 Likes

Actually, polling and sockets are not the same. With the action scheduler you could implement a polling system while sockets opens a bidirectional channel between server and client that stays open where events and data are sent continuously.

2 Likes

Example of websockets might be a interactive drawing workspace where you see the changes in realtime being made by users located elsewhere. Scheduling could be used to refresh the coordinates saved to the database of any change but its would be like watching a Netflix movie over a dialup connection (if you know what that was like) and an absolute nightmare!

1 Like

To avoid confusion with websocket and webrtc;

WebSocket and WebRTC are both projects that enable communication capabilities. These are two different ways to communicate with the server. WebSocket is a two-direction communication between the server and the client which implies that both parties can communicate and exchange data at the same time. With Web Real-Time Communication (WebRTC) , modern web-applications can easily stream audio and video content to millions of viewers and Screen-sharing technologies.

might be nice to try :slight_smile:

1 Like

Indeed! As a real life example, my company owns a research app that uses websocket to maintain a session environment which requires data exchange in realtime, including a sophisticated chat integration. It uses another technology written in python (Tornado) by external contractors, but I have a new app which I am creating in Wappler myself using nodejs without having to contract the job out. Most apps these days required a real-time data. It can be done with smoke and mirrors and other methods but having managed builds using “pretend” methods websockets is a much smoother user experience and so much more consistent and I have found reliable! Lets hope we get this soon and it will be a celebratory 2021 :grin:

1 Like

I haven’t started on chat functionality in my app, but as I’ve been working on other things I have noticed sockets in different parts of the code, or files, setup by the Wappler team. What is missing for you to create real time functionality?

It is possible what I’m showing is only scaffolding for features they are working on, but it seems like the main parts are there.

Looking at sockets.js and server.js it seems like most of what’s needed is setup for sockets to function. It may still need components in Wappler to make it easier to build, but you may be able to test it by following this guide. I would skip over anything about package.json or index.js. Start with the part talking about index.html and adding the scripts before the end body tag.

2 Likes