Archived

This forum has been archived. Please start a new discussion on GitHub.

::Ice::NoEndpointException JS to C#

I keep getting an ::Ice::NoEndpointException. I am attempting to connect a JS client to a C# server.

I know my server must be listening because when I use telnet to check so of see 'IceP' in the output.

My C# server has a lot of complicated abstraction around it to facilitate dependency injection, so I have pasted in the bits which I think matter below.

I don't think the problem is with the abstractions around the server, as I use the same code to faciliate an C# to C# connection in a different part of the application.

Let me know if you need to see anything else.

Server:

   ...

    protected Communicator Communicator { get; private set; }
    protected ObjectAdapter ObjectAdapter { get; private set; }  

     ...

 Communicator.createObjectAdapterWithEndpoints(HubName, GetProxyStringObjAdaptor(host, port)); //HubName: ScummWebServerHub5632 GetProxyStringObjAdaptor: default -h localhost -p 5632
 ObjectAdapter.add(Servant, Ice.Util.stringToIdentity(HubName));
 ObjectAdapter.activate();

    ...

Client:

 export async function InitProxy(hubName:string, port:number) {
    try {
        _communicator = Ice.initialize();
        _base = _communicator.stringToProxy(`${hubName}${port}:default -h localhost -p ${port}`); //"ScummWebServerHub5632:default -h localhost -p 5632"
        _scummWebServer = await ScummWebsServerVMSlices.ScummWebServerPrx.checkedCast(_base);
    }
    catch (ex) {
        if (_communicator) {
            await _communicator.destroy();
        }
        console.log(ex.toString());       
    }
}

Slice:

module ScummWebsServerVMSlices
{
    sequence<byte> GameData;
    dictionary<string, GameData> GameStorage;

    interface ScummWebServerClient 
    {
        bool SaveGame(GameData saveData, string fileName);
    }

    interface ScummWebServer
    {
      void addClient(ScummWebServerClient* receiver);
      void Init(string gameName, string gameId, string signalrConnectionId, GameStorage saveStorage); //Init and StartProcess
      void Quit(string signalrConnectionId);
      string GetControlKeys();
    }
}

Comments

  • xdm
    xdm La Coruña, Spain

    Hi Andrew,

    Your server is configured to listen on "default" transport, if you didn't change the default this is "tcp", a Java Script client on the browser can only connect to servers using "ws" or "wss" transports. You have to configure your server to use one of those, try using "ws -h localhost -p 5632" for your server endpoints.

    Cheers,
    Jose

  • manannan
    edited June 2020

    Hello Jose,
    Thanks for your time.

    You were right, and you fixed the issue.

    I don't want to overstate my credentials here, but could I suggest as a future improvement that if someone tries to connect to a server with a JavaScript client using anything other than ws that an error be thrown stating what you told me.

  • xdm
    xdm La Coruña, Spain

    Hi Andrew,

    Thanks for the suggestion, this is actually a bug in the JavaScript mapping, "default" should be ws for a browser and tcp for NodeJS, I miss you were getting NoEndpointException, I just observer your server was not listening on any ws endpoint, For a JavaScript browser client it should be the default, we will fix this.

    I added an issue in our github repository to track this https://github.com/zeroc-ice/ice/issues/934

    Thanks for reporting this issue