PDA

View Full Version : Can I forward everything to another Girder instance?



Mastiff
February 13th, 2008, 03:10 AM
I'm still playing around with virtual machines, and I would like to try to keep the full Girder setup on a VM. But to change all commands on all my computers (around 20 in the house, with physical and virtual machines) would be a major project, especially if it doesn't work as I hope, so I have to go back. So is there a way to make the Girder instance on 192.168.0.1 to forward all commands it gets from other computers and NetRemote instances to192.168.0.18, which is the VM I'm gonna use? I don't think Windows supports port forwarding on the internal network. At least not what I've found.

Edit: Just to clarify, I'm not talking about NetRemote feedback, only basic commands. And I do know that I need to use Remote Event Pump for the actual forwarding, but I'm not sure how to configure it to do the pump on any and all commands it gets.

Rob H
February 13th, 2008, 08:30 AM
You should just be able to add a remote event pump action to the machine on 192.168.0.1 - set the IP address to 192.168.0.18 and leave everything else blank.

Mastiff
February 13th, 2008, 08:40 AM
Thanks, Rob. But I tried that. I fired the remote event pump and it said "no event to pump". And sending an event to the 1 computer did not get any results, it didn't send anything to 18. If I add the event being sent from the client Girder to the remote event pump on 1, it will send the event to 18. And that I knew. But I was looking for something that didn't require me to copy every one of the (hughe bunch) of events in the old 1 GML to the remote event pump. Or isn't that possible? Do I need every to add event that will come in as a trigger?

If that makes it clearer I want to use computer 1 as a pure port forwarder.

Mastiff
February 13th, 2008, 01:52 PM
Should I guess that it isn't possible, then?

Rob H
February 13th, 2008, 03:46 PM
Hmm... it should be possible - as I understand things it's supposed to forward all events. I'll take a look at this tomorrow.

Mastiff
February 14th, 2008, 04:02 PM
Thanks, Rob! I'll be patient.

Mastiff
February 21st, 2008, 04:06 AM
Well, maybe not that patient... ;)

Marquis
February 21st, 2008, 06:27 AM
My first thought is going like this:

1. Write a Script action and make it responsible for all events
2. Inside the script take the event that is coming in and forward it to your 2nd machine

Too easy?
BR/Marc

Rob H
February 21st, 2008, 07:28 AM
Okay, looks like I was wrong about the Remote Event Pump treescript action - it only forwards the events that trigger it to the remote girder.

Looks like we need a bit of Lua to send all events e.g.


require 'Girder2Girder'

gir.AddEventHandler('.*', 0, 99999,
function(eventstring, device, modifier, payloads, handler)
g2g.SendEvent(eventstring, device, modifier, unpack(payloads))
end)

If you want to only send to one PC then use


require 'Girder2Girder'

gir.AddEventHandler('.*', 0, 99999,
function(eventstring, device, modifier, payloads, handler)
g2g.ClientSendEvent('lorne', eventstring, device, modifier, unpack(payloads))
end)

Where you'd replace 'lorne' with the name or IP address of the machine running Girder. In either case you'd have to put it in quotes.

Mastiff
February 21st, 2008, 08:47 AM
Thanks! I ran this as a script on the relaying computer (192.168.0.11) and set it to forward it to 192.168.0.1, but nothing got forwarded when I sendt the message "test" to the relaying computer. Is there something I didn't understand here?

Rob H
February 21st, 2008, 09:38 AM
Can you post the exact script that you used?

Mastiff
February 22nd, 2008, 11:32 AM
Sure. I used your script with this slight modification, just to test it (I ran it on another VM and tried to send to the actual server:

require 'Girder2Girder'

gir.AddEventHandler('.*', 0, 99999,
function(eventstring, device, modifier, payloads, handler)
g2g.ClientSendEvent('192.168.0.1', eventstring, device, modifier, unpack(payloads))
end)
Then I just sendt "Test" to the relaying computer from a third computer, and the relaying computer received it, but didn't send anything to the 192.168.0.1. I tried with 'Server' instead of the IP, but that didn't change anything.

Rob H
February 23rd, 2008, 04:14 AM
Hmm... I wonder if there's a routing problem here. Can you try it between two real computers?

Mastiff
February 23rd, 2008, 06:27 AM
That didn't change anything. What did was to do a full reset of both the sending and the relaying computer. I have no idea what it was, but now I have it working. Thanks, Rob! :D

Rob H
February 23rd, 2008, 07:59 AM
Cool, weird, but cool :)

Mastiff
February 23rd, 2008, 08:27 AM
Cool stuff is often weird... Anyway I have almost everything up and running now, I'm only fighting a bit with the Generic X10 USB driver (not the Girder plug-in). I'm starting to wonder if that's only for XP.

I have bought a new mainboard and a Q6600 (same type of CPU that I'm using in the HDPC), and I'm gonna build a new server, with maximum separation. One VM for Girder, one for media server parts and so on. I'm figuring I'll have four or five VM's on that computer. With 4 gig of Ram and a slight overclock to 3 gHz this shouldn't be a problem. :)

Mastiff
February 23rd, 2008, 11:25 AM
Found the problem. The generic X10 and Phidgets or USB-UIRT (probably the Generic X10 and anything more than one other USB unit, I suspect) won't play nice. Not a problem, though. The nice, little script of yours forwards those key presses as well to the VM. Running Girder in a VM by itself was a bit of work, but I do believe I've got something here! This way I don't ever have to restart or shut down the actual server, no matter how badly I screw up with Lua or other stuff in the Girder setup!

Mastiff
February 23rd, 2008, 11:46 AM
Keeping the thread active by myself here... Rob, is it possible to avoid some G2G events being pumped? I have a few events that has to stay on the physical server, since they are done locally (mostly related to the whole house media playback system, commands to JRMC). Is there any solution for that?

Edit: I tried to put in this, but it didn't work:

require 'Girder2Girder'

gir.AddEventHandler('.*', 0, 99999,
function(eventstring, device, modifier, payloads, handler)
If evenstring == "Test" then
print("Test")
else
g2g.ClientSendEvent('192.168.0.1', eventstring, device, modifier, unpack(payloads) end)
end)
(I'm not sure if the End is in the right place here, I got it in the right place when I experimented, but it didn't help)

Rob H
February 24th, 2008, 03:01 AM
Try this


require 'Girder2Girder'

gir.AddEventHandler('.*', 0, 99999,
function(eventstring, device, modifier, payloads, handler)
if eventstring == "Test" then
print("Test")
else
g2g.ClientSendEvent('192.168.0.1', eventstring, device, modifier, unpack(payloads))
end
end)

Mastiff
February 24th, 2008, 05:05 AM
Thanks, Rob! That works for "Test"! So the basics are in. I tried to expand it so that I could use a standard prefix for commands that should stay on the Server. But of course my hysterically bad coding "skills" weren't up for that. "Server*" didn't give me anything, and I guess it's because it isn't a wildcard when I use it like that...

Rob H
February 24th, 2008, 06:00 AM
How are these events generated?

If you're using gir.TriggerEvent() then you could use a different device number and only forward that device to the other machine.

Mastiff
February 24th, 2008, 06:38 AM
They come through the comserver. So there's no difference in the event generation. The only event type that shouldn't be forwarded is the Webserver events. As of now they are forwarded, but since the webserver isn't turned on in the VM-Girder, it doesn't do any harm. And it gets executed in the physical server as well.

I'm starting to think that the main reason for my stability problems (2-3 forced Watchdog restarts of Girder every week is a stability problem!) is that the comserver doesn't like to be on a computer with two network cards on different subnets. If you remember some months back I found out that blocking the comserver port in the external (Internet) network card with a software firewall reduced the crashes with 9/10, or so. But I have been running the Phidgets on the VM Windows 2000 for more than a week without any crashes at all. So I think this will once and for all crush those problems. Also it's nice to be able to take with me the full Girder setup from one server to another by copying the VM! :D

Rob H
February 24th, 2008, 01:21 PM
If you can use a standard prefix of Server as you say then you could do something like


if string.find(eventstring, '^Server.+') then

Mastiff
February 24th, 2008, 03:06 PM
Thanks, Rob! That did the trick! :D Now I'm almost fully virtualized on Girder. The only plug-ins I'm keeping on the physical machine are the Generic X-10, Caller ID and Webserver. The first because I couldn't get X-10 to play ball with two other USB units connected to the VM, and the latter because this Girder VM is actually totally isolated from the Internet, so I can't do "caller ID lookups" and webserver calls to it.