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

ConnectionRefusedException when calling client function from server side

Hello everybody!

I'm getting a little frustrated about this exception I get.

I'm having a java server whose code looks like this:
try {
	InitializationData initData = new InitializationData(); = Util.createProperties();"ServerAdapter.Endpoints", "default -p " + portNo + " -h " + serverAddress);"Ice.Warn.Connections", "1");"Ice.IPv6", "0");

	communicator = Ice.Util.initialize(initData);
	serverI = new RemoteCamServerI(controller);

	Ice.ObjectAdapter providerAdapter = communicator.createObjectAdapter("ServerAdapter");


	providerAdapter.add(serverI, communicator.stringToIdentity("Server"));
	providerAdapter.activate();"RemoteCamService() - running");

	running = true;

} catch (Ice.LocalException e) {
} catch (Exception e) {

On the other side I have the client with following implementation for a Windows Store App:
	string PortAddressAsString = IceUtil::wstringToString(PortAddress.ToString()->Data());
	string proxy = "Server:default -p " + PortAddressAsString + " -h " + ServerAddress;

	Ice::InitializationData id; = Ice::createProperties();>setProperty("Server.Proxy", proxy);>setProperty("ClientAdapter.Endpoints", "default");>setProperty("Ice.ACM.Client", "0");>setProperty("Ice.IPv6", "0");

	_communicator = Ice::initialize(id);

	ServerPrx = CsRemoteCamServerPrx::checkedCast(_communicator->propertyToProxy("Server.Proxy"));

	Ice::ObjectAdapterPtr adapter = _communicator->createObjectAdapter("ClientAdapter");

	RemoteClientAdapter* Client = new RemoteClientAdapter();
	Ice::Identity ident = _communicator->stringToIdentity("Client");
	adapter->add(Client, ident);

	ClientPrx = CsRemoteCamClientPrx::uncheckedCast(adapter->createProxy(_communicator->stringToIdentity("Client")));


} catch (const Ice::Exception& ex)

When calling 'ServerPrx->login(ClientPrx)' everything is fine until I reach a function call back to the client. Then I get somethig like that:
-! 18.11.13 11:07:51:015 warning: Ice.ThreadPool.Server-0: dispatch exception:
   identity: Server
   operation: login
   remote host: remote port: 50951
       error = 0
   	at IceInternal.ConnectRequestHandler.getConnection(
   	at IceInternal.ConnectRequestHandler.sendRequest(
   	at IceInternal.Outgoing.invoke(
Caused by: Connection refused: no further information
   	at Method)

The weird thing is: I have the same code running for both a java and an android client so I blame th WinRT environment for my problems.

Any suggestions what I am missing here?


  • benoit
    benoit Rennes, France

    Did you check if it could be a firewall issue on your Windows 8 machine? It looks like it's not accepting connections on the address and port number 50951.

    You should also make sure your server and client use the right IP address and port number (see this FAQ for tips on how to verify this using network tracing).

  • Hi Benoit,

    thanks for your quick reply.

    Firewall on both machines are off. But when I enable network trace on the server it is obvious that on the function call to the client the connection tried to be established points to a port with the localhost address.

    So I treid to configure the Endpoints of my ClientAdapter like this: 'default -h'

    But when I do this, I get an runtime assert alert from IncomingConnectionFactory:1632 on the _communicator->createObjectAdapter("ClientAdapter") call.

    Determining the port for the ClientAdpater endpoint works instead...
  • benoit
    benoit Rennes, France
    Hi Markus,

    Thanks, we'll try to reproduce this assert.

    So is it working now after the change? If it's still not working, how did you set the Windows Store App network capabilities in the Visual Studio project? See How to set network capabilities on the Microsoft web site for more information on this.

  • Hi Benoit,

    still not working :-(

    I had the capabilities set correctly (Internet Client, Internet Client+Server, Private Network). I also tried it with all capabilitoes (except Document lib) without success.

    I'm using Visual Studio Express 2012 for development.

    Thanks for your effort!

  • benoit
    benoit Rennes, France
    Hi Markus,

    Why do you actually configure endpoints for the "ClientAdapter" object adapter in your client?

    According to your code, the object adapter is associated to the client connection (which effectively makes this client connection a "bi-dir" connection). Your client doesn't need to listen on any endpoints if he's using a bi-directional connection to dispatch incoming invocations.

    So you should create the client object adapter with:
    Ice::ObjectAdapterPtr adapter = _communicator->createObjectAdapter("");

    And remove the following property setting:>setProperty("ClientAdapter.Endpoints", "default");

    See the bidir demo from your Ice distribution for an example.