Reduce network messages on WebServer

Hi, i think this question is more related to HTML and JavaScrip than to embedded application but...

I got an embedded webserver that can use GET, HEAD and POST methods. I am monitoring some switches with the webserver. For now i am polling the board with the GET method to constantly get the switches state. That is consuming too much of the network band. Is there any better way to update the data on the server? Somethink like when i press a switch, it wil generate a interrupt and send some kind of message to the webpage with the data? The interrupt part is easy. I just dont know how to deal with the webpage.

Thank you!

--------------------------------------- Posted through

formatting link

Reply to
Sink0
Loading thread data ...

board

consuming

on

formatting link

--------------------------------------- Posted through

formatting link

Reply to
srl100

rd

ng

on

We will be doing something similar, so here it goes. You need a Java applet on the server. When downloaded to the client browser, it opens a connection back to the server for communications. After that, it's all Java.

Reply to
linnix

Google for long-polling. It's quite a widespread technique now. I use the JQuery library, and use the "ajax" method to make a HEAD request. If the server has nothing to say, it holds the connection open and doesn't respond until either it has something to say, or the connection times out. The browser is programmed to make a new request in any case, continually. It may re-use a persistent connection or it may not - persistence is actually irrelevant unless you need to minimise packets&latency.

This is how Facebook etc get page updates to your browser without you doing anything. (Actually it's just one of the ways, but it's the simplest and most likely to work).

Clifford Heath.

Reply to
Clifford Heath

I dont think adding Java to it would be possible haha, How would that work on the server side?

Wow, abbout the JQuery lib, i am going to try that. Do you have any JavaScript exaple that can perform that (i am very new to HTML programming, i just have to learn it for this specif implementation). Thank you!!

--------------------------------------- Posted through

formatting link

Reply to
Sink0

Your description seems vague -- the device that hosts the web server *has* the switches attached (accessible) to it. And, you are polling that web server *remotely* to query the state of the switches?

I.e., box W (box running web server) has switches attached to it ("somehow") and box R is sending queries *to* box W -- in effect, constantly reloading a particular web page that W is serving up?

Is there some reason you are married to using an HTTP protocol? Why not just open a TCP connection between the W and R boxes. Then, have box W *send* the state of the switches to box R each time there is a change in their state? Additionally, your protocol could allow R to *poll* W for the current state of the switches in case it "forgets" (e.g., startup).

In this way, you only pass messages that show real data. And, you can reduce that data to as terse a form as necessary (eliminate client side processing, etc.)

Reply to
D Yuniskis

See for more information on using long http requests for pushing data.

One thing to remember is that this method always ties up a connection - if there are many clients connected to the server, this could be an issue. It will also be a problem if the client makes too many connections to the server, as browsers normally have a limit to the number of connections they will hold open to any given server.

Reply to
David Brown

Who the hell mentioned Java? I certainly didn't.

Many people have written about it better than I can. Just use Google. You're on a learning curve though...

Reply to
Clifford Heath

The

Thank you!! I wil take a look on that!

Luis

--------------------------------------- Posted through

formatting link

Reply to
Sink0

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.