embedded node and catchup subscription

Hi

I’m playing around with an embedded node in a very simple service. But keep running into this exception:

[10,12:09:33.217,DEBUG] Catch-up Subscription to log: running…

[10,12:09:33.217,DEBUG] Catch-up Subscription to log: pulling events…

[10,12:09:33.311,DEBUG] Catch-up Subscription to log: dropping subscription, rea

son: CatchUpError System.AggregateException: One or more errors occurred. —> E

ventStore.ClientAPI.Exceptions.NoResultException: Expected response of EventStor

e.Core.Messages.ClientMessage+ReadStreamEventsForwardCompleted, received EventSt

ore.Core.Messages.ClientMessage+NotHandled instead.

— End of inner exception stack trace —

at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceled

Exceptions)

at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotifica

tion)

at System.Threading.Tasks.Task`1.get_Result()

at EventStore.ClientAPI.EventStoreStreamCatchUpSubscription.ReadEventsTill(IE

ventStoreConnection connection, Boolean resolveLinkTos, UserCredentials userCred

entials, Nullable1 lastCommitPosition, Nullable1 lastEventNumber)

at EventStore.ClientAPI.EventStoreCatchUpSubscription.b__0(O

bject _)

—> (Inner Exception #0) EventStore.ClientAPI.Exceptions.NoResultException: Exp

ected response of EventStore.Core.Messages.ClientMessage+ReadStreamEventsForward

Completed, received EventStore.Core.Messages.ClientMessage+NotHandled instead.<-

Is this happening on start up? Also are you using security?

Yes, on startup. No security…

The complete code:

using System;

using System.Reactive.Linq;

using EventStore.ClientAPI;

using EventStore.ClientAPI.Embedded;

using EventStore.ClientAPI.SystemData;

using EventStore.Core;

using EventStore.Projections.Core.Utils;

namespace DurableService

{

public class ServiceEntry

{

private ClusterVNode node;

private IEventStoreConnection connection;

public void Start()

{

node = EmbeddedVNodeBuilder.AsSingleNode()

.RunOnDisk(@“C:\Users\fsl\DurableServiceStorage”)

.RunProjections(ProjectionsMode.System)

.VerifyDbHashes()

.OnDefaultEndpoints()

.Build();

node.Start();

var settings = ConnectionSettings.Create()

.EnableVerboseLogging()

.UseConsoleLogger()

.Build();

var c = EmbeddedEventStoreConnection.Create(node, settings);

c.Connected += connection_Connected;

c.ConnectAsync();

}

public void Stop()

{

connection.Dispose();

node.Stop();

}

private void LogEventAppeared(EventStoreCatchUpSubscription arg1, ResolvedEvent arg2)

{

Console.WriteLine(“Log event {0}”, arg2.Event.Data.FromUtf8());

}

void connection_Connected(object sender, ClientConnectionEventArgs e)

{

connection = e.Connection;

Log(“connected”, DateTime.Now.ToString());

SetupSubscription();

Observable.Interval(TimeSpan.FromSeconds(3)).Subscribe(x => Log(“tick!”, DateTime.Now.ToString()));

}

private void SetupSubscription()

{

connection.SubscribeToStreamFrom(“log”, null, false, LogEventAppeared);

}

private void Log(string key, string value)

{

connection.AppendToStreamAsync(“log”, ExpectedVersion.Any, Create(key, value));

}

private EventData Create(string key, string value)

{

return new EventData(eventId: Guid.NewGuid(), type: “foo”, isJson: false, data: value.ToUtf8(), metadata: null);

}

}

}

Is this on dev or?

No, it’s latest nuget packages.

There have been some changes around this that are on dev IIRC

I would have to look at what the behaviour is/was with last binary
release. I will try this later.

Greg

That’s great. Thank you.

You have to wait for the node to become master.

Okay, I’ll try that.

There is an event off vnode for this (state changed)

Thank you both. It's working now.