Alachisoft / NCache

NCache: Highly Scalable Distributed Cache for .NET
http://www.alachisoft.com
Apache License 2.0
647 stars 123 forks source link

Can't connect with remote .Net client #3

Closed eeldivad closed 7 years ago

eeldivad commented 9 years ago

I wrote a simple .Net console client that works fine when running on the ncache server, but when I copy the exe to a different computer and run it, then I get error. Here's the code. Am I doing something wrong? I'm trying to manually connect to the cache server without a config file using the CacheInitParams.

namespace NcacheTest {
    class Program {
        static void Main(string[] args) {
            CacheInitParams config = new CacheInitParams();
            config.BindIP = "x.x.x.x";
            var servers = new List<CacheServerInfo>();
            servers.Add(new CacheServerInfo("x.x.x.x", 9800));
            config.ServerList = servers.ToArray();

            Cache cache = NCache.InitializeCache("mycache", config);

            int counter = 0;
            if(cache.Contains("counter"))
                counter = (int)cache.Get("counter");

            counter++;
            cache.Insert("counter", counter);

            Console.WriteLine(counter);
        }
    }
}

Here's the error:

c:\temp\ncache> dir

    Directory: c:\temp\ncache

Mode                LastWriteTime     Length Name
----                -------------     ------ ----
-a---         1/13/2015  12:25 PM     221184 Alachisoft.NCache.Web.dll
-a---         1/13/2015  12:25 PM      36864 Alachisoft.NCache.Runtime.dll
-a---         4/30/2015   3:47 PM         93 test.ps1
-a---         1/13/2015  12:25 PM     569344 Alachisoft.NCache.Cache.dll
-a---         1/13/2015  12:25 PM     368640 Alachisoft.NCache.Common.dll
-a---         1/13/2015  12:25 PM     110592 Alachisoft.NCache.Management.dll
-a---          2/3/2015   1:21 AM     134656 protobuf-net.dll
-a---         4/30/2015   4:28 PM        942 client.ncconf
-a---         1/13/2015  12:25 PM      32768 Alachisoft.NCache.Parser.dll
-a---         4/30/2015   5:07 PM       5632 NcacheTest.exe
-a---          1/7/2015   4:39 PM       9216 verifylicense.exe
-a---          1/7/2015   4:39 PM      16384 Alachisoft.NCache.Tools.Common.dll

c:\temp\ncache> .\NcacheTest.exe

Unhandled Exception: System.Exception: Invalid bind-ip-address specified in client configuration
   at Alachisoft.NCache.Web.Communication.Connection.PrepareToConnect(Socket client)
   at Alachisoft.NCache.Web.Communication.Connection.Connect(IPAddress ipAddress, Int32 port)
   at Alachisoft.NCache.Web.Communication.Broker.ConnectRemoteServer(Connection connection, IPAddress addr, Int32 port,
Boolean balanceNodes, Boolean importHashmap, Boolean registerNotifs, Exception& exception)
   at Alachisoft.NCache.Web.Communication.Broker.ConnectRemoteServer(Connection connection, RemoteServer server, Boolean
 registerNotifs)
   at Alachisoft.NCache.Web.Communication.Broker.StartServices(String cacheId, String server, Int32 port)
   at Alachisoft.NCache.Web.Caching.RemoteCache..ctor(String cacheId, Cache parent, CacheInitParams initParams, PerfStat
sCollector2 perfStatsCol)
   at Alachisoft.NCache.Web.Caching.NCache.InitializeCacheInternal(String cacheId, CacheInitParams initParams)
   at Alachisoft.NCache.Web.Caching.NCache.InitializeCache(String cacheId, CacheInitParams initParams)
   at NcacheTest.Program.Main(String[] args)
dobariya commented 9 years ago

@eeldivad .Please make sure to install Ncache on the machine you are running the code and also it is added to the server node as client node by addclientnode.exe