Atozed Forums
push data to browser - Printable Version

+- Atozed Forums (https://www.atozed.com/forums)
+-- Forum: Atozed Software Products (https://www.atozed.com/forums/forum-1.html)
+--- Forum: IntraWeb (https://www.atozed.com/forums/forum-3.html)
+---- Forum: English (https://www.atozed.com/forums/forum-16.html)
+----- Forum: IntraWeb General Discussion (https://www.atozed.com/forums/forum-4.html)
+----- Thread: push data to browser (/thread-1112.html)



push data to browser - MrSpock - 06-22-2019

intraweb 14

I have used a method to check server state with onAsyncTimer installed on browsers. Every second browser timer fires a question to the server. This takes too much traffic for 100 browser connected. How to implement that to push data to browser when for example server side timer detects a change and needs to notify browser to refresh its page.


RE: push data to browser - kudzu - 06-22-2019

HTML doesnt support push. Its all pull. You have to poll, but I suggest longer than 1 second.

Other methods of pull are to keep open the HTTP connection (not easy, and not fully reliable), or web sockets which until recently were not widely supported and require a lot of changes and extra code. There are web socket libraries for IW though. You can find them in Google.


RE: push data to browser - MrSpock - 06-22-2019

(06-22-2019, 03:50 PM)kudzu Wrote: HTML doesnt support push. Its all pull. You have to poll, but I suggest longer than 1 second.

Other methods of pull are to keep open the HTTP connection (not easy, and not fully reliable), or web sockets which until recently were not widely supported and require a lot of changes and extra code. There are web socket libraries for IW though. You can find them in Google.
So someone has told me that for some time there has been a technology to push data to browser so I do not have to ask the server all the time if there is a change. So instead of sending a couple of hundered async queries by browser, I just wait, which matters if I have a slow connection.

So you suggest, that intaweb does not have this feature included and I need to learn another technology and connect it to intraweb which is probably difficult to master with few tutorials?


RE: push data to browser - kudzu - 06-24-2019

"someone "

There are plenty of someone's who will sell you the moon. "someone" always has a pleasing answer because they don't even have the liability of a name let alone a need to help you.

As I said before, there are things such as websockets but they also create server liabilities and some proxies and other things still interfere with or prevent their usage in many cases.

You can use websockets with IW, but there are a lot of factors including the server software that will make a specific dependency (ie IIS, vs HTTP.sys, etc).

If you want something that is simple and reliable, polling is the current way and this is not because of IntraWeb, but because of how the web works today. Websockets like WebAssembly are the future, but unfortunately because of infrastructure are not fully viable today and these are the reasons they are not widely used yet.

https://developer.bring.com/blog/websocket-bug-hunt/
"7 years after the websocket standard was finalized, it still won’t work on a lot of corporate networks"

Why do you need 1 second polling? Are you creating a chat?


RE: push data to browser - MrSpock - 06-24-2019

(06-24-2019, 01:49 PM)kudzu Wrote: Why do you need 1 second polling? Are you creating a chat?
The idea was to create a server for many players for a board game using a clock for each player. So I need to take action as soon as the move was made. The application worked, 5000 lines of source code, but the idea was abandoned by me a couple of years ago due to too much traffic, 100 clients asking server every second to check a change in the database to see whether the move was made by the opponent. Besides I am no longer for the idea of games as an entertainment for anyone.


RE: push data to browser - DanBarclay - 06-24-2019

You might want to take a look at significant web sites that do things similar to what you are thinking. Something like eBay's bidding page might be a place to look. I'm guessing that you'll find the browser drives the activity, rather than the server.

Wireshark and Fiddler might be worth learning if you're not already a user.

Dan


RE: push data to browser - kudzu - 06-25-2019

Polling as you are doing now is a common way that they do it.. but 1 second is just way to frequent. Some use a "stuck open" HTTP connection as well, but some proxies will interfere with those as well.


RE: push data to browser - Alexandre Machado - 06-26-2019

IWMonitor component was created for that specific task: polling the server using a lightweight request until a pre-determined condition is met. When this condition is met, another "full" request (sync or async) is posted.

There is a demo here:

https://github.com/Atozed/IntraWeb/tree/master/XIV/Delphi/IWMonitor2

IWMonitor still polls the server, but the request doesn't lock the session nor the session list, so it performs much better than a IWTimer, for instance.