Jump to content


Photo
* * * * * 5 votes

LabVIEW, Websockets, and SVG


  • Please log in to reply
61 replies to this topic

#21 David Wisti

David Wisti

    Very Active

  • Members
  • PipPipPip
  • 113 posts

Posted 30 November 2011 - 03:42 PM

If echo.websocket.org is not working. You can also use the above websocket chat client with the following in host:

node.remysharp.com:8001

Note that the above websocket server does not echo back the chat. You can use Google Chrome and connect to the Websocket server at:

http://html5demos.com/web-socket

Edited by David Wisti, 30 November 2011 - 03:44 PM.


#22 ShaunR

ShaunR

    LabVIEW Archetype

  • Members
  • PipPipPipPipPipPip
  • 2,224 posts
  • Version:LabVIEW 2009
  • Since:1994

Posted 14 December 2011 - 02:49 AM

*
POPULAR

I've really got the web-socket bug now :yes:

http://screencast.com/t/TqFOatnbfmC

(frame rate is due to Jing, not the apps)
A positive attitude may not solve all your problems, but it will annoy enough people to make it worth the effort. (Herm Albright 1876-1944).

Founder and general mischief maker on www.labview-tools.com.
SQlite aficionado and websocket zealot.
If it 'aint in LabVIEW, then you 'aint got a clue!

#23 jgcode

jgcode

    LabVIEW Renegade

  • OpenG
  • PipPipPipPipPipPip
  • 2,397 posts
  • Location:Australia
  • Version:LabVIEW 2009
  • Since:2005

Posted 14 December 2011 - 04:16 AM

*
POPULAR

I've really got the web-socket bug now :yes:

http://screencast.com/t/TqFOatnbfmC

(frame rate is due to Jing, not the apps)


Nice mirror.

#24 ShaunR

ShaunR

    LabVIEW Archetype

  • Members
  • PipPipPipPipPipPip
  • 2,224 posts
  • Version:LabVIEW 2009
  • Since:1994

Posted 14 December 2011 - 06:44 AM


Nice mirror.

Yup. This is what she looks like, face-on.
Posted Image
A positive attitude may not solve all your problems, but it will annoy enough people to make it worth the effort. (Herm Albright 1876-1944).

Founder and general mischief maker on www.labview-tools.com.
SQlite aficionado and websocket zealot.
If it 'aint in LabVIEW, then you 'aint got a clue!

#25 jgcode

jgcode

    LabVIEW Renegade

  • OpenG
  • PipPipPipPipPipPip
  • 2,397 posts
  • Location:Australia
  • Version:LabVIEW 2009
  • Since:2005

Posted 14 December 2011 - 07:14 AM

I would have been more impressed if you posted that as a SVG instead of a jpg :P

#26 lordsathish

lordsathish

    Active

  • Members
  • Pip
  • 17 posts
  • Location:Bangalore, India
  • Version:LabVIEW 2010
  • Since:2008

Posted 14 December 2011 - 02:51 PM

ShaunR, Will you be posting your fixed code :)

#27 David Wisti

David Wisti

    Very Active

  • Members
  • PipPipPip
  • 113 posts

Posted 15 December 2011 - 08:46 PM

Wow that is a nice mirror! I've updated the Websocket code and wrapped everything into a class. Also updated the chat client and added in a chat server that echos back what you send. Still struggling with the close handshake and I'm not sure if its 100% yet.

Attached Files



#28 Jon Kokott

Jon Kokott

    Very Active

  • Members
  • PipPipPip
  • 176 posts
  • Location:Milwaukee, WI
  • Version:LabVIEW 2010
  • Since:2006

Posted 19 December 2011 - 04:48 PM

chorme "16.0.912.63 m" is immediately closing the connection, anyone got it to work?
Certified LabVIEW Architect

#29 Jon Kokott

Jon Kokott

    Very Active

  • Members
  • PipPipPip
  • 176 posts
  • Location:Milwaukee, WI
  • Version:LabVIEW 2010
  • Since:2006

Posted 19 December 2011 - 06:21 PM

I'm assuming that this information is correct for chrome:

http://tools.ietf.or...tocol-17#page-7
section 1.3

This says that the protocal uses a SHA-1 hash, whereas the example is using a MD5. I'll start with that is suppose.
Certified LabVIEW Architect

#30 Jon Kokott

Jon Kokott

    Very Active

  • Members
  • PipPipPip
  • 176 posts
  • Location:Milwaukee, WI
  • Version:LabVIEW 2010
  • Since:2006

Posted 19 December 2011 - 06:38 PM

So the connection is actually being established now (it was using the incorrect hash), but I get an error code 62 on the first write to the connection...
Certified LabVIEW Architect

#31 ShaunR

ShaunR

    LabVIEW Archetype

  • Members
  • PipPipPipPipPipPip
  • 2,224 posts
  • Version:LabVIEW 2009
  • Since:1994

Posted 20 December 2011 - 12:39 AM

ShaunR, Will you be posting your fixed code :)

Not sure what you mean by "fixed code". But I won't be releasing it until the api is completed and tested (it's a bit of a mess at the mo'). I'm currently up to supporting Hybi 17, 10,8, 6 and 00 (looking at Hixie and auto negotiation now) and have a prototype library for exporting events and commands (i.e. for remote monitoring), but still need to figure out the reciprocal methods. And, (this'll surprise a few people) some of it is LVOOP. :rolleyes: . Oh. And finally, you get events for errors, status, messages etc ;)
A positive attitude may not solve all your problems, but it will annoy enough people to make it worth the effort. (Herm Albright 1876-1944).

Founder and general mischief maker on www.labview-tools.com.
SQlite aficionado and websocket zealot.
If it 'aint in LabVIEW, then you 'aint got a clue!

#32 mje

mje

    The 500 club

  • Premium Member
  • 813 posts
  • Location:Milford MA USA
  • Version:LabVIEW 2011
  • Since:1997

Posted 20 December 2011 - 01:56 AM

*
POPULAR

And, (this'll surprise a few people) some of it is LVOOP. :rolleyes:

No way, say it's ain't so. In other news, the sky is still blue. Well on Earth anyways, most of the time...

I'm still pumped about this topic. Granted I got to spend zero time on implementing something like this this year (still very disappointed about that), but 2012 will be different. Yeah, that's it, different. What can I say, there's still a bit of foolish youthful optimism in me.

#33 ShaunR

ShaunR

    LabVIEW Archetype

  • Members
  • PipPipPipPipPipPip
  • 2,224 posts
  • Version:LabVIEW 2009
  • Since:1994

Posted 20 December 2011 - 02:05 AM

No way, say it's ain't so. In other news, the sky is still blue. Well on Earth anyways, most of the time...

I'm still pumped about this topic. Granted I got to spend zero time on implementing something like this this year (still very disappointed about that), but 2012 will be different. Yeah, that's it, different. What can I say, there's still a bit of foolish youthful optimism in me.

Yup. It's not as clean as I usually like (can't use polymorphic VI's with dynamic terminals) but I needed to maintain state on a per-connection basis. So this is one of the rare instances where it is the better choice. It won't happen again, I promise :D (Sky's always grey over here :P )

Edited by ShaunR, 20 December 2011 - 02:12 AM.

A positive attitude may not solve all your problems, but it will annoy enough people to make it worth the effort. (Herm Albright 1876-1944).

Founder and general mischief maker on www.labview-tools.com.
SQlite aficionado and websocket zealot.
If it 'aint in LabVIEW, then you 'aint got a clue!

#34 David Wisti

David Wisti

    Very Active

  • Members
  • PipPipPip
  • 113 posts

Posted 20 December 2011 - 04:35 PM

I'm currently up to supporting Hybi 17, 10,8, 6 and 00 (looking at Hixie and auto negotiation now)


I'm curious, why are you supporting older versions of the protocol? What is auto negotiation in Websockets?

#35 ShaunR

ShaunR

    LabVIEW Archetype

  • Members
  • PipPipPipPipPipPip
  • 2,224 posts
  • Version:LabVIEW 2009
  • Since:1994

Posted 20 December 2011 - 06:16 PM


I'm curious, why are you supporting older versions of the protocol? What is auto negotiation in Websockets?

Because (for example, currently) Chrome uses Hibi 10, Firefox uses Hybi 9, I.E 10 (will use) Hybi 10, IE.9 (with HTML5 Labs plugin) supports Hybi 6 and Safari (different flavours) supports Hixie 75,76 or Hybi 00.

The specs are still fluid and browsers are having difficulty keeping up. If it's to be robust, then really I have to support all of them and besides, some of my favourite stock tickers are still on the old versions :P

Auto-negotiation:
In the latest specs, there is a negotiation phase whereby the client requests a connection and the server replies back with the supported protocols. That's part of it (for the server). The other part is the brute force client connection whereby you iteratively try each protocol until one works. This is one of the reasons why I needed to move to a class since with multiple connections all (potentially) talking different protocols, the reads and writes need to switch on each call and maintain their state (i.e closed, connecting etc). Rather than writing a connection manager, it made sense to bundle that info with the class data. Besides. this is TCPIP over HTTP so performance is secondary :lol:

Edited by ShaunR, 20 December 2011 - 07:10 PM.

A positive attitude may not solve all your problems, but it will annoy enough people to make it worth the effort. (Herm Albright 1876-1944).

Founder and general mischief maker on www.labview-tools.com.
SQlite aficionado and websocket zealot.
If it 'aint in LabVIEW, then you 'aint got a clue!

#36 smarlow

smarlow

    More Active

  • Members
  • PipPip
  • 35 posts
  • Location:Maryland
  • Version:LabVIEW 2011
  • Since:1993

Posted 20 January 2012 - 11:13 PM

*
POPULAR

Hello, Everybody, I am back!

I have finished an 'alpha' version of the SVG demo program that complies with the new websocket protocol (RFC6455). Below is a rough list of release notes, along with a 'to do' list that I will be working on in the coming weeks.

Changes:

1. Changed the handshake and websocket read/write VI's to conform to the RFC6455 version of the websocket protocol currently supported by Chrome 16.

2. Replaced the string indicator on the main front panel with a dialog that pops up when a message is received from the client (from clicking the buttons and switch on the SVG document.

3. Tested the demo with Chrome version 16.0.912.75 m. Seems to work OK so far. If you find bugs, let me know. I did not test the script and program with any other browser. I use Chrome exclusively, with the intention of using this system with Android tablets and Chrome OS. I do not currently own a tablet, so if anyone tests it, please

4. Cleaned up the folder system for the project and got rid of the RGraph library demo, as well as a bunch of other files that were not used and cluttering up the folders. I will no longer be working with the RGraph library, and will instead focus on the webpanel library.

As with the previous version, open the WebPanel project and the SVGDemo VI. Run the VI, then open the \www\WebPanelTest.svg file on the same computer. It should connect to the listener and begin updating.

Disclaimer:
Please test and use the library however you wish. No warranty is implied, and I am not responsible for anything that happens as a result of using this code. Downloading the file acknowledges this disclaimer.


Attached File  WPLavaG.zip   529.8K   141 downloads

LabVIEW 2009 or later is required. Please contact me for earlier versions (will need 8.5 min due to the use of classes).


My to do list (not necessarily in the order presented here)

1. Change my web host to a suitable provider and migrate the files to a subversion directory.
2. Rework the websocket Labview Class and add dynamic dispatching to accomodate future revisions of the websocket protocol
3. Change the SVG namespace of the webpanel objects to shorten the name.
4. Clean up and document the ecmascript file and look at new methods of controlling the objects.
5. Document the SVG elements and create new objects.
6. Fully document everything in a PDF file, with commentary on methodology
7. Create new website with documentation and file download area.
8. Offer the package to OpenG.org
9. Change the protocol to binary
10. Migrate the ecmascript engine to open source.

Please post your comments/questions on this version here, or message me privately if you wish. Thanks, everyone, and happy SVG'ing.

I should also note the LabVIEW side of the demo does not cleanly close the websocket on shutdown, as I have not yet added any control frames to the new protocol. Also,in case you missed it, while the new protocol supports binary, I opted for text so I wouldn't have to make any changes to the javascript. Obviously, binary is a better choice, but that is down the road because it will require the data parsing portion of the script to be overhauled. I also want to spend some time thinking about what the binary protocol should look like. Any thoughts on this subject are welcome. I hope to have the new website up and running sometime before the end of Feb.

#37 ShaunR

ShaunR

    LabVIEW Archetype

  • Members
  • PipPipPipPipPipPip
  • 2,224 posts
  • Version:LabVIEW 2009
  • Since:1994

Posted 22 January 2012 - 01:08 PM

I noticed that you had this in your JS

top.wpSend = wpSend; //for sending webpanel msg from HTML if SVG is embedded. Firefox 4 only (no Chrome)

I'm guessing this comment is because you get a x-server script error when using chrome to access a "file://" URI (i.e a local file rather than an "http://" URI). You can override this limitation by launching chrome with the command-line switch "-allow-file-access-from-files". You should then be able to connect after opening an html file on the local file system without an error.
A positive attitude may not solve all your problems, but it will annoy enough people to make it worth the effort. (Herm Albright 1876-1944).

Founder and general mischief maker on www.labview-tools.com.
SQlite aficionado and websocket zealot.
If it 'aint in LabVIEW, then you 'aint got a clue!

#38 jgcode

jgcode

    LabVIEW Renegade

  • OpenG
  • PipPipPipPipPipPip
  • 2,397 posts
  • Location:Australia
  • Version:LabVIEW 2009
  • Since:2005

Posted 22 January 2012 - 01:36 PM

...because you get a x-server script error when using chrome to access a "file://" URI (i.e a local file rather than an "http://" URI). You can override this limitation by launching chrome with the command-line switch "-allow-file-access-from-files". You should then be able to connect after opening an html file on the local file system without an error.


Using a web-server in the past has fixed my XSS issues (among other things).
I am interested to try out the switch you have posted i.e. does it allow cookies to work in chrome?

#39 ShaunR

ShaunR

    LabVIEW Archetype

  • Members
  • PipPipPipPipPipPip
  • 2,224 posts
  • Version:LabVIEW 2009
  • Since:1994

Posted 22 January 2012 - 01:53 PM


Using a web-server in the past has fixed my XSS issues (among other things).
I am interested to try out the switch you have posted i.e. does it allow cookies to work in chrome?

No-eyed-deer. This is purely a mismatch in the URI which chrome resricts by default (firefox, Safari and explorer don't exhibit this behaviour). I have only had this problem with websockets since I have never had the need to send cookies from labview. So I guess if your cookie issue works in the other browsers but not in chrome, then maybe it will solve it- you tell me ;)
A positive attitude may not solve all your problems, but it will annoy enough people to make it worth the effort. (Herm Albright 1876-1944).

Founder and general mischief maker on www.labview-tools.com.
SQlite aficionado and websocket zealot.
If it 'aint in LabVIEW, then you 'aint got a clue!

#40 smarlow

smarlow

    More Active

  • Members
  • PipPip
  • 35 posts
  • Location:Maryland
  • Version:LabVIEW 2011
  • Since:1993

Posted 22 January 2012 - 07:44 PM

I noticed that you had this in your JS

I'm guessing this comment is because you get a x-server script error when using chrome to access a "file://" URI (i.e a local file rather than an "http://" URI). You can override this limitation by launching chrome with the command-line switch "-allow-file-access-from-files". You should then be able to connect after opening an html file on the local file system without an error.


Thanks for the tip. I had put that function in for use with HTML form buttons when the user was embedding the script in an HTML file. I could never get the function to work with Chrome, but it worked with Firefox. I'll try it again with your suggestion. Like I said, I really need to clean up the script, as I have a bunch of notes to myself in there, and some code that was used merely for debugging. I plan to revise it and release it again on the new website. Thanks for your help.