View Single Post
  #1  
Old 10-16-2012, 05:53 AM
fordprefect fordprefect is offline
Member
 
Join Date: Oct 2012
Location: Vienna, Austria, Europe
Posts: 39
Question Problems using viznet.client.connect

Hi,

I am trying to set up automated server-client connection between the machines in our virtual reality network. Our network consists of 3 computers (MASTER, HEAD1, HEAD2). Working with the basic elements from the Vizard Help > Reference > Networking > Multi User environment works fine. But this approach needs always the master starting first, then the client, and when the master is disconnected it does not reconnect. So I was playing around a bit but ran into several issues:

1. When reading Help: the command index for <viznet:client>.connect says Return Value: None. Whereas when I look into the Reference>Networking>viznet or ..>Multi User Environment, the return value of this command is always used like in
Code:
if viznet.client.connect('MASTER'):
    print 'connected'
2. Trying to test it in interactive mode out of the Vizard IDE on HEAD1 but bad luck:
Code:
>>> import viz
>>> import viznet
>>> viznet.client.connect('MASTER')
    False
The result is always the same, even if 'MASTER' is on the network and started the Vizard IDE, and issuing there in interactive mode these commands:
Code:
>>> import viz
>>> import viznet
>>> viznet.server.start()
I found a similar thread from some time ago but without a solution posted.

3. Because we already use the command successfully from script, next thing I try is putting these commands into a python script:
Code:
import viz
import viznet

_networkMachines = ('MASTER', 'HEAD1', 'HEAD2', 'HEAD3')

for machine in _networkMachines:
    print 'testing machine:', machine,
    if viznet.client.connect(machine):
        print ' -> connected +++'
        viznet.client.disconnect()		# (1)
    else:
        print 'does not run a server ---'

if viz.net.getName().upper() == 'HEAD1':
    viznet.server.start()

viz.go()
Given the following scenario:
HEAD1: executing script & starting server and the simulation
HEAD2: online being idle, not running Vizard
HEAD3: not on the network
MASTER: executing the script, displaying the following output result:
Code:
testing machine: MASTER  -> connected +++
testing machine: HEAD1  -> connected +++
testing machine: HEAD2  -> connected +++
** ERROR: Failed to connect to 'HEAD3'
testing machine: HEAD3 does not run a server ---
Which leaves me with the impression that viznet.client.connect does just a ping on the requested machine but not really confirms a handshake connection at all.

BTW, without the line marked with (1) even HMD3 would look like connected; so it seems further that viznet.client.connect returns True when already connected, ignoring that the connection request was for another machine.

If I am not doing anything wrong, then I would recommend that WorldViz changes the connect command in that it only returns true when there is indeed a connection established with the requested machine, meaning that there runs the server. And returns a couple of errors like
  • not on the network
  • not running viznet.server
  • before connecting to {requestedServer} you have to close existing connection to {currentServer} first (disconnect).

Any comments and/or ideas and/or solutions?
Thanks, Walter
Reply With Quote