나는 Ubuntu VM에서 실행되는 Zookeeper v3.3.3 + dfsg2-1ubuntu1을 사용하고 있습니다. zkCli.cmd -server 10.10.135.19:2181
그것을 잘 연결하고 나는 create
의, 나는이의 등 get
아파치를 사용하는 C# 응용 프로그램에서 ZooKeeper에 연결할 수 없습니다. .NET 라이브러리
을 수행 할 수 있습니다 내가 실행하는 경우, 내 개발 시스템에서
(윈도우 7)을합니다 (VM는 NAT 네트워크 연결 실행) Org.Apache.ZooKeeper v1.0.0.0에 NuGet 종속성이있는 C# 4 응용 프로그램.
나는 다음과 같은 방법을 사용하고 있습니다 :
class watcher : IWatcher
{
private readonly ManualResetEventSlim _connected = new ManualResetEventSlim(false);
private WatchedEvent _event;
public void WaitUntilConnected()
{
_connected.Wait();
if (_event == null) throw new ApplicationException("bad state");
if (_event.State != KeeperState.SyncConnected)
throw new ApplicationException("cannot connect");
}
public void Process(WatchedEvent @event)
{
_event = @event;
_connected.Set();
}
}
...
public void TestZooKeeper()
{
_countdownWatcher = new watcher();
_zk = new ZooKeeper(
Settings.Default.ZookeeperConnectionString, // 10.10.135.19:2181
new TimeSpan(Settings.Default.ZookeeperConnectionTimeout), // 10000
_countdownWatcher);
_countdownWatcher.WaitUntilConnected();
}
문제는이 그냥 달려 있다는 것입니다. 사육사 로그에, 나는 다음을 참조 :
2012-04-05 08:12:21,376 - INFO [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:[email protected]] - Accepted socket connection from /10.0.2.2:51057
2012-04-05 08:12:21,379 - INFO [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:[email protected]] - Client attempting to establish new session at /10.0.2.2:51057
2012-04-05 08:12:21,383 - INFO [SyncThread:0:[email protected]] - Established session 0x1367c91bf580047 with negotiated timeout 4000 for client /10.0.2.2:51057
2012-04-05 08:12:22,500 - INFO [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:[email protected]] - Accepted socket connection from /10.0.2.2:51059
2012-04-05 08:12:22,502 - INFO [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:[email protected]] - Client attempting to establish new session at /10.0.2.2:51059
2012-04-05 08:12:22,505 - INFO [SyncThread:0:[email protected]] - Established session 0x1367c91bf580048 with negotiated timeout 4000 for client /10.0.2.2:51059
2012-04-05 08:12:26,000 - INFO [SessionTracker:[email protected]] - Expiring session 0x1367c91bf580047, timeout of 4000ms exceeded
2012-04-05 08:12:26,001 - INFO [ProcessThread:-1:[email protected]] - Processed session termination for sessionid: 0x1367c91bf580047
2012-04-05 08:12:26,004 - INFO [SyncThread:0:[email protected]] - Closed socket connection for client /10.0.2.2:51057 which had sessionid 0x1367c91bf580047
2012-04-05 08:12:28,001 - INFO [SessionTracker:[email protected]] - Expiring session 0x1367c91bf580048, timeout of 4000ms exceeded
2012-04-05 08:12:28,002 - INFO [ProcessThread:-1:[email protected]] - Processed session termination for sessionid: 0x1367c91bf580048
2012-04-05 08:12:28,004 - INFO [SyncThread:0:[email protected]] - Closed socket connection for client /10.0.2.2:51059 which had sessionid 0x1367c91bf580048
내가 즉, WaitUntilConnected()
방법은 반환하지 않습니다, 수동으로 프로세스를 종료 때까지 계속된다. (디버깅으로 확인)
클라이언트 연결이 서버에 정상적으로 연결되어있는 것처럼 보이지만 Watcher는이를 인식하지 못하고 클라이언트에서 다시 시도 할 때만 해당 채널에서 서버에서 아무 것도 일어나지 않으며 채널에서 아무 일도 일어나지 않습니다. 내가 여기서 잘못하고있는 아이디어는?
은 watcher.Process라고 불립니다. – miniBill
번호. 나는 소스 코드를 조금 밟았다. 내부적으로 연결 상태는 ZK 서버에서 소켓의 첫 번째 응답을 읽으려고 시도 할 때 CONNECTING 상태를 지나서 도달하지 않습니다. –
wireshark와 같은 도구를 사용하여 클라이언트와 코드 연결의 차이점을 확인할 수 있습니다. – miniBill