Home Help Center

ICE Connectivity (C# client to C++ server)

vaibhavvaibhav Member Vaibhav BhattOrganization: WiproProject: OTK

Hi,

we are using zeroc.ice nuget package in one of our application. Our client is in C# and server is in c++. I have generated the c# code
from .ice file.

When I try to connect with server using checkedCast server, I am getting below error:/
Ice.ObjectNotExistException: 'Exception of type 'Ice.ObjectNotExistException' was thrown.'

And from server end when I checked, we are able to hit the server but at server too we are getting the error.

reply status = 5 (unknown local exception)
unknown = ../../include/Ice/BasicStream.h:175: Ice::UnsupportedEncodingException:
protocol error: unsupported encoding version: 1.1
(can only support encodings compatible with version 1.1)
/production_q2/general/ice/lib64/libIce.so.34: IceInternal::BasicStream::throwUnsupportedEncodingException(char const*, int, unsigned char, unsigned char)
../bin/icegridregistry: IceInternal::BasicStream::startReadEncaps()

Let me know if any other details needed.

Thank you,
Vaibhav

Answers

  • xdmxdm La Coruña, SpainAdministrators, ZeroC Staff Jose Gutierrez de la ConchaOrganization: ZeroC, Inc.Project: Ice Developer ZeroC Staff

    This exception indicates that your client is trying to talk to an Ice 3.4 server using the 1.1 encoding, the 1.1 encoding is supported with Ice 3.5 or later.

    If you cannot upgrade your server to a more recent Ice version you will have to use the 1.0 encoding, see https://doc.zeroc.com/technical-articles/general-topics/encoding-version-1-1#EncodingVersion1.1-InteroperabilitywithIce3.4andearlierreleases

  • vaibhavvaibhav Member Vaibhav BhattOrganization: WiproProject: OTK

    yes I tried to change the address like:

    var address = string.Format("Grid/Locator -e 1.0:tcp -h {0} -p {1}", "addressdom.com", "40");

    Is this is the correct way?

    Now I am getting null result from from b.ice_isA function?

    please suggest

    Thank you,
    Vaibhav

  • xdmxdm La Coruña, SpainAdministrators, ZeroC Staff Jose Gutierrez de la ConchaOrganization: ZeroC, Inc.Project: Ice Developer ZeroC Staff

    Is Grid/Locator the correct identity, if your client is still getting ObjectNotExistException you are probably trying to reach an object that doesn't exist on the server,

    The IceGrid locator Identity is <IceGrid.InstanceName>/Locator

  • vaibhavvaibhav Member Vaibhav BhattOrganization: WiproProject: OTK

    exact url is below I have made changes in url and port for security purpose.

    var address = string.Format("QMatoIceGrid/Locator -e 1.0:tcp -h {0} -p {1}", "testdom.com", "40");

    After adding encoding not getting objectNotExistException, but now in checkedCast function getting NULL
    in b.ice_isA(ice_staticId()) function call.

    it is a internal function b.ice_isA in ice library.

    below is the code for your reference.

    OperationHandlerIcePrx r = b as OperationHandlerIcePrx;
    if((r == null) && b.ice_isA(ice_staticId()))
    {
    OperationHandlerIcePrxHelper h = new OperationHandlerIcePrxHelper();
    h.iceCopyFrom(b);
    r = h;
    }

  • xdmxdm La Coruña, SpainAdministrators, ZeroC Staff Jose Gutierrez de la ConchaOrganization: ZeroC, Inc.Project: Ice Developer ZeroC Staff

    This indicates that the target object doesn't implement the given interface, can you show the code doing this checkedCast?

  • vaibhavvaibhav Member Vaibhav BhattOrganization: WiproProject: OTK

    I haven't made any changes in that code. It was automatically got created from Ice file.

    Below is the code for your reference:

    public static OperationHandlerIcePrx checkedCast(global::Ice.ObjectPrx b)
    {
    if(b == null)
    {
    return null;
    }
    OperationHandlerIcePrx r = b as OperationHandlerIcePrx;
    if((r == null) && b.ice_isA(ice_staticId()))
    {
    OperationHandlerIcePrxHelper h = new OperationHandlerIcePrxHelper();
    h.iceCopyFrom(b);
    r = h;
    }
    return r;
    }

    private static readonly string[] _ids =
    {
    "::Ice::Object",
    "::QMatoIce::OperationHandlerIce"
    };

        public static string ice_staticId()
        {
            return _ids[1];
        }
    

    Let me know if you need any other details.

  • xdmxdm La Coruña, SpainAdministrators, ZeroC Staff Jose Gutierrez de la ConchaOrganization: ZeroC, Inc.Project: Ice Developer ZeroC Staff

    I mean the code where you create the proxy and invoke checkedCast

  • vaibhavvaibhav Member Vaibhav BhattOrganization: WiproProject: OTK

    ohh.. yes, please see below

            using (Ice.Communicator communicator = Ice.Util.initialize(ref args))
            {                
                var address = string.Format("QMatoIceGrid/Locator -e 1.0:tcp -h {0} -p {1}", "testserver2dom.com", "40");
             var testcon = communicator.stringToProxy(address);
             var conn = OperationHandlerIcePrxHelper.checkedCast(testcon);
               if (conn == null)
                {
                    throw new ApplicationException("Invalid proxy");
                }
               var pp = conn.QMOperation("", null, "");
            }
    
  • xdmxdm La Coruña, SpainAdministrators, ZeroC Staff Jose Gutierrez de la ConchaOrganization: ZeroC, Inc.Project: Ice Developer ZeroC Staff

    Seems you are trying to cast the IceGrid/Locator to your own type, a null proxy is expected as IceGrid does not implement this type.

    Typically you will set the default locator to use the IceGrid/Locator and this will be used to resolved indirect references.

    You should check the IceGrid/demos https://github.com/zeroc-ice/ice-demos/tree/3.5/democs/IceGrid/simple

    The client configures its default locator in https://github.com/zeroc-ice/ice-demos/blob/3.5/democs/IceGrid/simple/config.client#L4

    And this allows the client to resolve indirect references https://github.com/zeroc-ice/ice-demos/blob/3.5/democs/IceGrid/simple/Client.cs#L45

    You should consider upgrading your servers to 3.7.4 the latest stable release

  • vaibhavvaibhav Member Vaibhav BhattOrganization: WiproProject: OTK

    we can not make any changes on server. we are using zeroc.ice.net(3.7.4) in our client app (.net core). All the details which I have for making the connection is provided by the c++ developer.

    Can you please suggest what changes I should make so that I can establish a connection to server.

    I am also unable to set the default locator. Can you please guide how to create default locator?

    Ice.GetDefaultlocator() is returning null to me.

    if you can share any example would be great help.

    thanks for your support.

  • xdmxdm La Coruña, SpainAdministrators, ZeroC Staff Jose Gutierrez de la ConchaOrganization: ZeroC, Inc.Project: Ice Developer ZeroC Staff

    Can you please suggest what changes I should make so that I can establish a connection to server.

    When you create the testcon proxy you need to use the identity and./or endpoints of the object implementing OperationHandlerIce

    Ice.GetDefaultlocator() is returning null to me.

    You need to set Ice.Default.Locator configuration property or use ice_locator proxy method
    https://doc.zeroc.com/ice/3.7/client-side-features/proxies/proxy-methods

    Ice.InitializationData initData = new Ice.InitializationData();
    initData.properties = Ice.Util.createProperties();
    initData.properties.setProperty("Ice.Default.Locator", 
         string.Format("QMatoIceGrid/Locator -e 1.0:tcp -h {0} -p {1}", "testserver2dom.com", "40"));
    using(Ice.Communicator communicator = Ice.Util.initialize(initData))
    {
        var conn = OperationHandlerIcePrxHelper.checkedCast(communicator.stringToProxy("hello"));
        if (conn == null)
        {
            throw new ApplicationException("Invalid proxy");
        }
        var pp = conn.QMOperation("", null, "");
    }
    

    Where "hello" is the object you when to contact, how you create this proxy depends a bit on what the server provides. If it is a well know object the Id might be enough otherwise you might need to include the server endpoints.

    https://doc.zeroc.com/technical-articles/general-topics/the-fundamentals-of-proxies#TheFundamentalsofProxies-ProxyTypes

  • vaibhavvaibhav Member Vaibhav BhattOrganization: WiproProject: OTK


    Thank you for your help.

    Now the code looks like below:

    Ice.InitializationData initData = new Ice.InitializationData();
    initData.properties = Ice.Util.createProperties();
    initData.properties.setProperty("Ice.Default.Locator",
    string.Format("QMatoIceGrid/Locator -e 1.0:tcp -h {0} -p {1}", "testServer.com", "40"));

            using (Ice.Communicator communicator = Ice.Util.initialize(initData))
            {
                var conn = **OperationHandlerIcePrxHelper.checkedCast(communicator.stringToProxy("C_wipro2QmatoFacadeAdapter"));**
                if (conn == null)
                {
                    throw new ApplicationException("Invalid proxy");
                }
                var pp = conn.QMOperation("", null, "");
            }
    

    Now I am getting error unknown local error exception. Now I am sure that the error is coming due to object "C_wipro2QmatoFacadeAdapter". I have tried couple of more object but getting same error.

    C++ developer from our team has shared one image with me regarding the connection and end point. I am attaching here for your reference.

    Please have a look and let me know if you have any idea?

    thank you,
    Vaibhav

  • xdmxdm La Coruña, SpainAdministrators, ZeroC Staff Jose Gutierrez de la ConchaOrganization: ZeroC, Inc.Project: Ice Developer ZeroC Staff

    The string pass to comunicatorToProxy should be the same you are using in C++, probably the whole ICE_FACADE_NAME value: "[email protected]_wipro2QmatoFacadeAdapter"

  • vaibhavvaibhav Member Vaibhav BhattOrganization: WiproProject: OTK

    I have one more question for you..

    I have a client application which has latest ice version (3.7.4) and in server we have 3.4.2.

    Do we need to have both with the same version?

  • xdmxdm La Coruña, SpainAdministrators, ZeroC Staff Jose Gutierrez de la ConchaOrganization: ZeroC, Inc.Project: Ice Developer ZeroC Staff

    You can use different versions, but you have to stick to the 1.0 encoding as 3.4.2 doesn't support 1.1 introduced in Ice 3.5

  • vaibhavvaibhav Member Vaibhav BhattOrganization: WiproProject: OTK

    Now connection is established now I am getting error on operation call to server:
    Error: reply status = 4 (operation not exist)

    When we call the same operation from c++ client it is working with version 3.4.2.

    But with the latest version 3.7.4 (C# client) we are getting this error.

    Please suggest

  • xdmxdm La Coruña, SpainAdministrators, ZeroC Staff Jose Gutierrez de la ConchaOrganization: ZeroC, Inc.Project: Ice Developer ZeroC Staff

    There isn't much info here for us to know, if the checked cast succeeds it means that the object implements the desired interface, it would be interesting to see the protocol tracing of both the client that works and the client that fails. You can enable protocol tracing by set "Ice.Trace.Protocol=1", we might be able to pinpoint the difference by looking at both traces.

Sign In or Register to comment.