ECatsBlog
  • Home
  • Web Dev
  • Reviews
  • Thoughts
  • ASP
  • SQL
  • Browser
  • Mobile
  • Cloud
  • CMS
  • ECommerce
  • App Hacks
  • Fixes
  • Mapping
  • 3D Printing
  • XAML
  • SEO

Categories

  • 3D Printing (1)
  • App Hacks (5)
  • ASP (22)
  • Browser (13)
  • Cloud (10)
  • CMS (7)
  • ECommerce (6)
  • Fixes (5)
  • Mapping (1)
  • Mobile (12)
  • Reviews (70)
  • SEO (9)
  • SQL (12)
  • Thoughts (60)
  • Uncategorized (1)
  • Web Dev (94)
  • XAML (9)

Archives

  • October 2024 (2)
  • December 2022 (1)
  • October 2022 (1)
  • February 2022 (1)
  • June 2019 (1)
  • January 2019 (175)
  • December 2018 (47)

(Web)Socket to me

When Written: Oct 2011


WebSockets could be a very important extension to the HTML 5 specification.

Yesterday Microsoft announced another update to their HTML 5 WebSockets prototype (http://html5labs.interoperabilitybridges.com/prototypes/websockets/websockets/info). This may not seem of any great significance until you realise just what WebSockets can bring to your web application. Imagine the scenario where you have constantly changing data that you want to display on a web page.

You could just leave it for the user to click on refresh to get the next value but this causes the server to return the whole page again which is a waste of server resources as well as being very clumsy. The other drawback is that in the case of a very busy site the server can be brought to its knees by users constantly clicking on the refresh button and a new page having to be returned irrespective if the data value has changed.

A slightly better solution is to auto refresh the web page, but whilst this may reduce the number of users clicking multiple times it still means that the server has to return the whole page ( less any browser cached items ) even if the data has not changed. Using a JavaScript function to call a specific URL that returns a value that is then written into a <div> area on the page is a better and much lighter-weight solution.

However if the value is not changing very often or in an erratic manner as in the case of sports results for example then this solution would still be making calls to the server every ten seconds or so, again a solution that does not scale too well. What is needed is some method of the server ‘pushing’ the data to the client browser when, and only when, the data has changed. To do this a channel of communication has to be established and kept open constantly between the user agent and the server.

This channel can be structured in such a way that it presents a minimal demand on the resources on the server and so should scale well as it can also be spread across a server farm or within the Cloud. Reactive Extensions are one such solution, which I have mentioned here before, although implementing these is not for the faint hearted. What seems to be an easier to implement solution could be possibly the WebSocket Protocol, the draft of which is in the HTML 5 specification.

Once this becomes a standard in all major browsers I am sure we shall see lots of implementations. For now there is a prototyping layer that you can download to use with your own site. As with a lot of this sort of early development code it is a little tricky to get working, and I had a lot of trouble compiling the demos into an exe that would run on the webserver,  but initial results are promising and I hope to use it on a live site in the next month or so and will be able to report back on the viability of using this technology on a live and busy web site.

Article by: Mark Newton
Published in: Mark Newton

  • Previous Access Problems6 years ago
  • Next AJAX or Ajax? It depends if you are using Microsoft development tools it seems6 years ago

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recent Posts

  • .net application moving files
  • Dealing with accents on database driven web site
  • Neat feature in Chrome
  • Unable to ping VM machine from host
  • SMTP Email Client

Recent Comments

    2025 ECatsBlog. Donna Theme powered by WordPress