locked
Partner with service running in another machine RRS feed

  • Question

  • Hi All,

     

    I have Service A running in one machine and Service B running in another machine and Service A uses Service B. How can I specify in the Partner attribute that is introduced in Service A to partner with Service B that Service B is located in another machine?

     

    Thanks,

     

    Venkat

    Friday, October 28, 2011 9:09 PM
    Moderator

Answers

  • By the way as a tip id suggest you to put the remote services locally with other services for testing. As I found the hard way that a firewall was blocking the ports and was causing the dropping of packets.
    Im new to the world of VPL. Hence why im here :)
    Friday, November 4, 2011 5:57 AM

All replies

  • As far as I know you cant specify that in the partner attribute.

    I normally subscribe to a remote partner for notifications through a ServiceForwarder. This might be the recommended way as well.


    Im new to the world of VPL. Hence why im here :)
    Saturday, October 29, 2011 6:47 AM
  • I suggest you to have a read through Trevor and Kyle's book, "Professional Microsoft Robotics Developer Studio". Very useful.
    Im new to the world of VPL. Hence why im here :)
    Saturday, October 29, 2011 6:53 AM
  • Hi Kasunt,

     

    Thanks for your time and reply. I am reading Trevor and Kyle's book, "Professional Microsoft Robotics Developer Studio" and I am finding it very useful.

     

    I believe one of the ways by which we can create service remotely is by using CreateService(ConstructorPort constructorPort,

    ServiceInfoType serviceInformation). How do I pass a constructor port of a remote machine so that the service is created in that machine?

     

    Thanks,

     

    Venkat

    Friday, November 4, 2011 4:42 AM
    Moderator
  • Hi,

    Like I said you can use a ServiceForwarder to do this. Trevor's book explains this very well.

    Heres how i have done it in my project. I'm sure people here who have far better knowledge about MRDS than myself might choose to do it differently.

     

    using ds = Microsoft.Dss.Services.Directory;
    
    using dssp = Microsoft.Dss.ServiceModel.Dssp;
    
    
    
    const string host = "your host"
    
    const int port = 50000;
    
    UriBuilder builder = new UriBuilder("http", host, port, "directory");
    
    botProxy.BotOperations _botPort = null;
    
    ds.DirectoryPort dirPort = ServiceForwarder<ds.DirectoryPort>(builder.ToString());
    
    dssp.ServiceInfoType serviceInfo = new dssp.ServiceInfoType(botProxy.Contract.Identifier, null);
    
    ds.Query query = new ds.Query(new ds.QueryRequestType(serviceInfo));
    
    dirPort.Post(query);
    
    Activate(Arbiter.Choice(query.ResponsePort, delegate(ds.QueryResponseType response)
    
    {
    
      dssp.ServiceInfoType res = response.RecordList[0];
    
      _botPort = ServiceForwarder<botProxy.BotOperations>(res.Service);
    
      _botPort.Post(Whatever message you want);
    
    }
    

     


    Im new to the world of VPL. Hence why im here :)
    • Proposed as answer by gunnnModerator Monday, November 21, 2011 9:26 PM
    Friday, November 4, 2011 5:36 AM
  • By the way as a tip id suggest you to put the remote services locally with other services for testing. As I found the hard way that a firewall was blocking the ports and was causing the dropping of packets.
    Im new to the world of VPL. Hence why im here :)
    Friday, November 4, 2011 5:57 AM
  • Hi kasunt,

     

    Thanks once again for your time and reply. It was very helpful. However, I need a few clarifications. The code you have given above seems like a code to connect to a service that is already running in a machine. Suppose, I want to create a service in a remote machine, then how should I do it? How do I talk to the constructor service of the remote machine and create this service on that remote machine.

     

    Thanks,

     

    Venkat

    Thursday, November 10, 2011 2:21 PM
    Moderator
  • Hi kasunt,

     

    I used the code that you gave me and I seem to be facing the same kind of problem. I have four services. They are TestService, CalculatorService, TranscedentalService and BinaryArithmeticService. TestService, CalculatorService and TranscedentalService run on one machine (say Machine A). BinaryArithmeticService runs on another machine with the name "keckcontroller". Machine A has robotics studio installed. BinaryArithmeticService was originally in Machine A and was deployed in "keckcontroller" using "dssdeploy". TestService partners with CalculatorService using the partner attribute. CalculatorService in turn partners with TranscedentalService (using the partner attribute) and BinaryArithmeticService (using the code you gave me in your previous post). I started the BinaryArithmeticService on "keckcontroller" using DssHost that came with dssdeploy. After that, when I run the TestService on machine A, I am getting the error message. The error occurs when my CalculatorService tries to find the directory service of "keckcontroller:50000" so that it can partner with the BinaryArithmeticService.

     DsspForwarder:OutboundFailureHandler. Exception:HttpTransport.ProcessOutboundPacket: Failure writing to stream after N retries. Action:http://schemas.microsoft.com/xw/2004/10/dssp.html:QueryRequest Body Type:Microsoft.Dss.Services.Directory.Proxy.QueryRequest Target Service:http://keckcontroller:50000/directory Source Service:http://bio4072953.asurite.ad.asu.edu:50000/calculatorservice/e813101d-7afd-454e-bce8-4f735fabbddd

     

     

    As you said before, it appears the packets are not accepted at "keckcontroller" because of some firewall settings.

    Based on some tips from online sources, I turned "off" the firewall in the "keckcontroller" machine. However, now I seem to get a different error when my CalculatorService tries to find the directory service of "keckcontroller:50000"

    ### DsspForwarder:OutboundFailureHandler. Exception:System.Net.WebException: The remote server returned an error: (401) Unauthorized. at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult) at Microsoft.Dss.Services.Transports.Http.HttpTransportService.HandleHttpPostResponse(IAsyncResult Res) Action:http://schemas.microsoft.com/xw/2004/10/dssp.html:QueryRequest Body Type:Microsoft.Dss.Services.Directory.Proxy.QueryRequest Target Service:http://keckcontroller:50000/directory Source Service:http://bio4072953.asurite.ad.asu.edu:50000/calculatorservice/1c0fdb7f-be11-4ae1-86e3-4b34c25a5db2

     

    It appears that I need to give some user credentials. I tried to access the service in the other machine directly from the browser by typing  "http://keckcontroller:50000/directory". It prompted for an user id and password. I entered "keckcontroller\admin" (one of the admin users for the keckcontroller machine that I am trying to connect to) and the password. It does not seem to accept.

    Firstly,  I am not very comfortable with turning the firewall off as it makes the system vulnerable. Hence, can you please tell me the "best" and "secure" way of doing what I am trying to do.

     

    Thanks,

     

    Venkat

    Monday, November 14, 2011 4:11 PM
    Moderator
  • You need to partner with the remote node's constructor service and create by contract. I would start with getting this to work locally first and then distributing to the remote machine.

    Thanks

    Nick

    Monday, November 21, 2011 9:26 PM
    Moderator