Help with Network Tools

liik's picture

Hi,

I've purchased the Network tools plugin, but have some problems utilizing them properly. I'm not experienced in setting up such communication and i need some assistance.

What i'm trying to do is to control a composition from a webpage opened on a smartphone. The webpage server is a local apache2 server on the same computer as the composition and works well when i load it on the computers browser.

I tried changing the TCP port input on the patch to some standard port numbers with no go. I only got a response (saying Path:/ and the smartphone's IP on the network) from the composition when i load http://xxx-xxx-xxx.lan:8080 in the smartphone browser.

What am am i doing wrong?

jstrecker's picture
Re: Help with Network Tools

A couple of things that might help--

  • Unless you're root, you can't use ports below 1024.

  • You should be dealing with 2 different ports here. There's the port that your webpage server is running on, for communicating between the smartphone and the webpage server. And there's the port that your webpage is using to send commands to the composition. (Notice in the NetworkTools example composition that the webpage sends a request to http://localhost:8080/, and the port on the HTTP Server patch is also set to port 8080.)

If you still need help, could you post your composition and webpage?

liik's picture
Re: Help with Network Tools

That clarifies it a bit for me, still i don't know how to control the composition from other computers or smartphones. I'm a total noob at this.

I'm posting the composition and the webpages. They are a sketch of what i'm trying to do, based on the example composition that came with the plugin.

tnx

PreviewAttachmentSize
Quiz.qtz49.15 KB
quiz1.html984 bytes
quiz2.html984 bytes

jstrecker's picture
Re: Help with Network Tools

OK, the problem is in the Javascript function (sendToQC). When you click a button in quiz1.html, the function sends a request to http://localhost:8001/. Problem is, if you're looking at quiz1.html on your phone's web browser and you click the 'A' button, your phone tries to go to http://localhost:8001/A on your phone, not on the web server.

It works for me if I replace 'localhost' in the Javascript with the IP of the web server. You can probably find a more robust solution...

liik's picture
Re: Help with Network Tools

Works fine now. Thanks for taking the time to explain.

Cheers!

liik's picture
Re: Help with Network Tools

Hi, again,

I've had several QC crashes now with a notice saying "QC crashed while using network tools". I've tried modifying the comp several times but it just works for 15 min and then crashes. Could someone take a look at the crash report and the qtz? The same thing happens both on a mac pro and a macbook pro.

Thanks!

PreviewAttachmentSize
crashReport3.rtf64.34 KB
1.html1017 bytes
Q.qtz129.53 KB

mirek's picture
Re: Help with Network Tools

you can use WebSocket plugin http://github.com/mirek/quartzcomposer-websocket to communicate to/from web page.

smokris's picture
Re: Help with Network Tools

@liik: Looking at your composition... you have multiple instances of the Kineme HTTP Server patch all listening on the same port. This probably isn't going to work as expected, since a TCP port can only have one binding at a time.

Consider refactoring your composition so that you have a single Kineme HTTP Server patch instance, then connecting its output to various other macros to handle the different possible responses.

(I haven't been able to reproduce your crash yet; still trying.)

jstrecker's picture
Re: Help with Network Tools

@liik: I haven't been able to reproduce the crash either, after running the composition for over 30 minutes. Did refactoring your composition fix the problem?

liik's picture
Re: Help with Network Tools

It crashed when i used the http server as a single instance, and multiple instances on different ports (my mistake on posting the comp with same ports on 4 instances). So far i've been using 4 copies of the same .html on 4 different TCP ports. I will now try using 4 different .html files on one port. Strange that no one gets a crash when both my macs fail. @mirek: will also try the websocket plugin

Again, thnx for your suggestions.

gtoledo3's picture
Re: Help with Network Tools

small note: I'm not sure it's inherently a mistake to attempt to use multiple of the same provider... bad form, maybe because of redundancy and the fact it makes the graph larger, but a user wouldn't typically expect stuff to not work from having done that. Simply put, don't give yourself a lashing, there's no reason you should expect things to not work, imo.

liik's picture
Re: Help with Network Tools

...works better and "longer" with one instance of the HTTP Server, but i still get some crashes...tried disabling all unused plugins and no result. I've started using osc messages sent from a server one friend programed for this purpose and that works great.

jstrecker's picture
Re: Help with Network Tools

Glad you found a solution.

FWIW, This problem is now fixed in NetworkTools 1.2. Thanks for reporting it.

mirek's picture
Re: Help with Network Tools

if you want to try websockets here's the video: http://t.co/Fy7TfaE downloads: https://github.com/mirek/quartzcomposer-websocket/archives/master (3x files - plugin, example qtz and example html page).

jstrecker's picture
Re: Help with Network Tools

@mirek -- One "shameless plug" is sufficient. Don't spam the thread.

usefuldesign.au's picture
More help with Network Tools…

Not sure if I should start a new thread with this question (feel free to move my post)… What I'd really like to do is have two quartz compositions talk to each other via Network Tools, is this possible? (I'll settle for any method doesn't have to involve Network Tools!)

Normally OSC patch would be fine but in cases where there is no local network, I'd like to be able to send a composition to you and then we have two way comms between our compositions.

Is this unrealistic with Network tools — can it only talk to a browser, what essentially is a browser doing to talk to the Network Tools server.

Do I need fixed IP addresses or dynamic okay? So many questions because I know nothing about servers and clients :-)

jstrecker's picture
Re: More help with Network Tools…

Here's an example of a composition that sends data to another composition. The sender composition is counting the number of times you click, and it sends that to the receiver.

Your sending composition needs to have an HTTP Query and your receiving composition needs to have an HTTP Server, and they should be using the same port. You can have 2-way communication if each composition has both an HTTP Query and an HTTP Server -- just make sure you don't have multiple HTTP Server patches using the same port if they're running on the same machine, or they'll fight.

The HTTP Query patch is doing basically the same thing your browser is doing when you go to a URL, in terms of how it communicates with the HTTP Server.

The attached example assumes both compositions are running on localhost. If you want to run them on separate machines on a network, the HTTP Query patch will need to know (in the URL) the IP address or domain name of the machine that the other composition is on. And you might have to mess with the firewall.

PreviewAttachmentSize
NetworkTools sender.qtz4.21 KB
NetworkTools receiver.qtz3.25 KB

usefuldesign.au's picture
Re: More help with Network Tools…

[removed]

usefuldesign.au's picture
Re: More help with Network Tools…

Are there any theoretical/practical limits on the length of the string that gets sent from Query Patch to the Server Patch? (I'm running into a 100 char limit with the stock Apple Network Patch that kills the transmission — which is one reason I'm looking at using NetworkTools possibly it's more versatile too).

JSON to QC Structure patch is quite handy for de-coding so I'l look at making a JS patch to encode a QC structure to JSON for sending, or is Raw to Data a more compact way to send a structure of keyed string/float/int/bool data?

Also I can't remember the name of the patch that converts a string to URL friendly string (eg. a space: ' ' –> '%20' and a double quote ( " ) –> '%22' ) — I think it's a Kineme DataTools patch from memory but not coming up in my Patch Browser :–P

If anyone wants to contribute I'm going to try and get the Simon game working multiplayer over internet as a demo comp. I've made the nice artwork and a basic triangle hit-testing comp will post on a new thread.

gtoledo3's picture
Re: More help with Network Tools…

( I think the stock Network Patch has a 256 character limit... not that it changes your need.)

I don't know the answer about the raw data/network tools thing, as I haven't used it, but you can parse out %20 (and file://localhost), using String Replace. There's a file somewhere here called "audio click.qtz" that does this.

usefuldesign.au's picture
Re: More help with Network Tools…

Thanks George. I might post my stock Network patches demo comps. I posted them to the Apple list last week showing Network Patch failing above about 100char length but received no replies (usually the list is a better source of fixes for my issues so I posted their first). As one doesn't get your own emails through the list I don't know if it saw the light of day though ;-)

I'm aware of String Replace, (and recently mastered GREP too!) but I'm thinking I remember a patch that converts lots of non-alphanumeric glyphs to those URL style '%20' codes (don't even no what they're called they're a bit different to the Unicode Hex codes one uses in HTML mark-up eg: &#8195 for an em space).

usefuldesign.au's picture
Re: More help with Network Tools…

Yes, that's it. Thanks.

Interestingly it uses a built-in JS method:

function (__string outputEscapedString) main (__string inputString)
{
   var result = new Object();
   result.outputEscapedString = escape(inputString);
   return result;
}