Home AMX User Forum AMX General Discussion

HTTP Server Push?

Any one got any insight on sever push? I have the master acting as a web server for iPhone/PC control and everything is working fine. I have 24 buttons per page (configurable) and up to ten pages available. This acts like a normal web page (sort of) so when you push a button it triggers the master (server) and does its thing and then after couple second delay (time for values to change) it sends an amended web page out displaying feedback. My button's turn on that should and I even have level feedback for lights via button shadow levels (100 shades from yellow - black) in the returned html doc.

I was then playing witht he AMX virtual keypad I noticed that their page updates automatically, no page refresh needed, no new get/post required. If someone changes a light for instance from anywhere the display on the iPhone/PC will show it with out initiating another HTTP client/server session so I figured the AMX module must not be closing the server connection after the client connects and therefore is able to PUSH updates to the iPhone/PC any time a value changes. I then figured I could do the same by not closing the connection after serving a page but so far no joy.

Once the password to log on is approved I send a "set-cookie" command which the iPhone/PC happily replies with on subsequent POST/GET's but if I try to leave the server running I think the client is dropping the connection and nothing works.

Anyone been down this road and have any tips/tricks they'd like to share. Are there values to send with the header other than keep alive that will actually keep the connection alive.

TIA

Comments

  • mpullinmpullin Posts: 949
    vining wrote: »
    Anyone been down this road and have any tips/tricks they'd like to share. Are there values to send with the header other than keep alive that will actually keep the connection alive.
    Eh... Persistent connections are not really supported by the HTTP standard. It's designed to be a connect-request-receive type experience. Most applications that appear to "push" actually work by polling.
  • viningvining Posts: 4,368
    I haven't had any like witht the server push approach but I did find this META line that will make the web page issue a GET/HTTP 1.1 request automatically at the interval set.
    <META HTTP-EQUIV="refresh" CONTENT="15">
    
    which is the same request I get from a new client but at least with this request it includes my cookie so if I see this I send a refresh and not the login page. I can live with this.

    In the example it's set to send another "GET" every 15 seconds. I'm sure if I look I can find a timeout feature.
  • viningvining Posts: 4,368
    This "META" refresh works pretty good but if you have multiple tabs open on your browser I was hoping in wouldn't refresh if it not in focus (being viewed) but it still does until you actually close that page.

    Still not so bad.

    I still think the server PUSH is possible since on my web page when it does its refresh you see the broswer is busy refreshing but with the AMX virtual kp single page version you don't get that indication so me thinks their connection stays "alive" and the master is a pusher.

    I think I would prefer maintaining an constant connection and just updating the iPhone/PC when values change than every x amount of second sending a get and receiving the entire html regardless of there being chnages or not.

    I'd also like to know how the AMX VKP works. If you view source on the keypad you get an xml style sheet which refer to href="http/virtualkeypad.xsl on the master. The index.html in the VP folder on the master is just a redirect to:<meta http-equiv="REFRESH" content = "0; URL=/web/module/VirtualKeypad/com.amx.virtualkeypad/virtualkeypad"/> which I can't find any reference to even if I go up a level from the users folder to where vxWorks and PROG.tkn reside..

    I don't supposed AMX would like to share their secrets?
  • viningvining Posts: 4,368
    In order to minimize traffic and not resend the entire html upon every client refresh I went and put a flag in my level event handler which is how I'm supplying values to my module. On any level event I set the flag and now on a refresh request which essential a GET/ HTTP 1.1 which also contains a valid cookie, I'll send the modified html. If the flag for new values isn't set I'll now just send a HTTP/1.1 304 Not Modified header w/ no content (obviously) so now there's considerably less traffic and I'm not actually refreshing the page unless a value has changed.

    It's much better but I still want to know how the AMX vkp is working.
  • a_riot42a_riot42 Posts: 1,624
    vining wrote: »

    It's much better but I still want to know how the AMX vkp is working.

    Could they be using AJAX?
    Paul
  • viningvining Posts: 4,368
    That does look like a possiblity. AJAX doesn't look like a connection less HTTP though which could have huge benfits over what I'm trying to do.

    Actually what I'm doing is just a quick fix since this isn't a proper connection protocol for a GUI. Ideally this should a be an app that maintains a connection and the GUI graphics should live on the GUI and only the FB values that change should be sent, hmmm kind of like the touch panel. Lutron has an iPhone app that work via a telnet conection and it would be so easy for AMX to make their own.

    There's also a Network Ping Lite app (free download) that allows you to ping, tracert and open a telnet session where you can log in and control the master. It's a great tool just to have a jobsite.
  • a_riot42a_riot42 Posts: 1,624
    vining wrote: »
    Ideally this should a be an app that maintains a connection and the GUI graphics should live on the GUI and only the FB values that change should be sent, hmmm kind of like the touch panel.

    I did something similar with the last company I worked with except that it was a java applet that looked like the touch panel UI that communicated with the controller, so the page didn't need to refresh. To use html and keep feedback updated I would think that AJAX or some other DHTML method would be needed if refreshes are to be avoided. Java had the benefit of running as an applet in a browser or as a stand alone application on either Mac or PC.
    Paul
  • PhreaKPhreaK Posts: 966
    vining wrote: »
    I'd also like to know how the AMX VKP works. If you view source on the keypad you get an xml style sheet which refer to href="http/virtualkeypad.xsl on the master. The index.html in the VP folder on the master is just a redirect to:<meta http-equiv="REFRESH" content = "0; URL=/web/module/VirtualKeypad/com.amx.virtualkeypad/virtualkeypad"/> which I can't find any reference to even if I go up a level from the users folder to where vxWorks and PROG.tkn reside..

    If you dive into the java module for the vkp you will see everything in there. They are using the jQuery javascript library for an AJAX implimentation and it polls the server once every 3 seconds for updates. From what I've been able to tell the masters use a java based web server (hence the web interface speed boost when you up the duet memory) - http.jar which sits in doc:/LIB/. The management interface is named morpheus and can also be found in there. When you've got the virtual keypad module on your system this is then instantiated and all the assets placed into somewhere in memory that the web server can access, thus the request to /web/module/VirtualKeypad/com.amx.virtualkeypad/virtualkeypad/. This modular web server side of things is interesting as it appears that AMX have put into place a framework where hopefully we may have access to write our own web modules for http based control.

    Also, I should add that I have not, and do not intend to ever modify, recompile or repurpose any component of this, or any other AMX software.
  • viningvining Posts: 4,368
    FYI, the HTTP / 304 trick only worked w/ IE. With Safari or Mozilla it will refresh twice but then drops the connection. Oh well!
Sign In or Register to comment.