Skip to content

Instantly share code, notes, and snippets.

@mbp

mbp/eventstore-problem.cs Secret

Created Apr 15, 2014
Embed
What would you like to do?
using System;
using System.Net;
using EventStore.ClientAPI;
using EventStore.ClientAPI.SystemData;
namespace EventStoreProblem
{
class Program
{
private static int _eventCount = 0;
static void Main(string[] args)
{
var connectionSettings =
ConnectionSettings.Create()
.UseConsoleLogger()
.SetDefaultUserCredentials(new UserCredentials("admin", "changeit"))
.KeepReconnecting()
.OnReconnecting(OnReconnecting)
.OnDisconnected(OnDisconnected)
.OnConnected(OnConnected)
.OnErrorOccurred(OnErrorOccured)
.OnAuthenticationFailed(LogAuthenticationFailed)
.OnClosed(OnClosed);
var eventStoreConnection = EventStoreConnection.Create(connectionSettings, GetIpEndPoint());
eventStoreConnection.Connect();
eventStoreConnection.SubscribeToAllFrom(null, false, EventAppeared, LiveProcessingStarted, SubscriptionDropped);
Console.ReadLine();
}
private static IPEndPoint GetIpEndPoint()
{
var ipAddress = IPAddress.Parse("127.0.0.1");
return new IPEndPoint(ipAddress, 1113);
}
private static void SubscriptionDropped(EventStoreCatchUpSubscription arg1, SubscriptionDropReason arg2, Exception arg3)
{
Console.WriteLine("SubscriptionDropped");
}
private static void EventAppeared(EventStoreCatchUpSubscription arg1, ResolvedEvent arg2)
{
Console.WriteLine("EventAppeared {0}", _eventCount++);
}
private static void LiveProcessingStarted(EventStoreCatchUpSubscription obj)
{
Console.WriteLine("LiveProcessingStarted");
}
private static void OnClosed(IEventStoreConnection arg1, string arg2)
{
Console.WriteLine("OnClosed");
}
private static void LogAuthenticationFailed(IEventStoreConnection arg1, string arg2)
{
Console.WriteLine("LogAuthenticationFailed");
}
private static void OnErrorOccured(IEventStoreConnection arg1, Exception arg2)
{
Console.WriteLine("OnErrorOccured");
}
private static void OnConnected(IEventStoreConnection arg1, IPEndPoint arg2)
{
Console.WriteLine("OnConnected");
}
private static void OnDisconnected(IEventStoreConnection arg1, IPEndPoint arg2)
{
Console.WriteLine("OnDisconnected");
}
private static void OnReconnecting(IEventStoreConnection obj)
{
Console.WriteLine("OnReconnecting");
}
}
}
@mbp

This comment has been minimized.

Copy link
Owner Author

@mbp mbp commented Apr 15, 2014

Output:

[14,07:13:21.127,DEBUG] Connected to [172.31.50.209:1113, L192.168.1.102:62196,{8155c3df-8b48-4456-8fe4-a3f0069b07ba}].
OnConnected
15-04-2014 07:13:22 EventAppeared 0
15-04-2014 07:13:22 EventAppeared 1
[manually trimmed output here]
15-04-2014 07:13:22 EventAppeared 498
15-04-2014 07:13:22 EventAppeared 499
[11,07:13:25.512,INFO] EventStoreConnection 'ES-aee8292d-7860-4009-a181-37ce2e69e61b': closing TCP connection [172.31.50.209:1113, L192.168.1.102:62196, {8155c3df-8b48-4456-8fe4-a3f0069b07ba}] due to HEARTBEAT TIMEOUT at pkgNum 2.
[11,07:13:25.515,INFO] [07:13:25.515: N172.31.50.209:1113, L192.168.1.102:62196, {8155c3df-8b48-4456-8fe4-a3f0069b07ba}]:
Received bytes: 4018530, Sent bytes: 133
Send calls: 4, callbacks: 4
Receive calls: 809, callbacks: 808
Close reason: [Success] EventStoreConnection 'ES-aee8292d-7860-4009-a181-37ce2e69e61b': closing TCP connection [172.31.50.209:1113, L192.168.1.102:62196, {8155c3df-8b48-4456-8fe4-a3f0069b07ba}] due to HEARTBEAT TIMEOUT at pkgNum 2.

[11,07:13:25.518,DEBUG] Connection [172.31.50.209:1113, L192.168.1.102:62196, {8155c3df-8b48-4456-8fe4-a3f0069b07ba}] was closed cleanly.
OnDisconnected
OnReconnecting
[17,07:13:25.758,DEBUG] Connected to [172.31.50.209:1113, L192.168.1.102:62197,{166adb6e-408c-4719-b063-9e4fefb6e94d}].
OnConnected
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.