Hello guys.
Disclaimer: Beginner here
I’ve just started looking at the event store and I’m having some difficulties getting it to work. The idea is just to write a simple “event” to the event store. Here’s my code:
using EventStore.ClientAPI;
using System;
using System.Text;
using System.Threading.Tasks;
using System.Net;
using Newtonsoft.Json;
namespace eventstoretests {
class Program
{
static void Main(string[] args)
{
DoIt();
Console.ReadLine();
}
public static async Task DoIt() {
var settings = ConnectionSettings.Create()
.EnableVerboseLogging()
.OnAuthenticationFailed((c, info) => Console.WriteLine(“autherr”))
.UseConsoleLogger()
.OnDisconnected((c1, ip) => Console.WriteLine(“oopsss”))
.OnErrorOccurred((c, ex) => Console.WriteLine(ex.ToString()))
.SetDefaultUserCredentials(new EventStore.ClientAPI.SystemData.UserCredentials(“admin”, “changeit”));
var cnn = EventStoreConnection.Create(settings, new IPEndPoint(IPAddress.Loopback, 2113));
var aggId = Guid.NewGuid();
await cnn.ConnectAsync();
try {
await WriteEvents(cnn, aggId, ExpectedVersion.NoStream, new Test(Guid.NewGuid(), 1));
await WriteEvents(cnn, aggId, 1, new Test(Guid.NewGuid(), 2));
}
finally {
cnn.Close();
}
}
const string _baseStream = “Test”;
public static async Task WriteEvents(IEventStoreConnection cnn, Guid aggId, int expectedVersion, Test @event) {
var bytes = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(@event));
await cnn.AppendToStreamAsync(
_baseStream + “-” + aggId,
expectedVersion,
new EventData(@event.Id,
_baseStream,
true,
bytes,
null));
}
}
class Test {
public readonly Guid Id;
public readonly int Version;
public Test(Guid id, int version) {
Id = id;
Version = version;
}
}
}
Looking at the console, I can see there’s an error saying Invalid TCP frame received:
[06,21:23:27.392,ERROR] Invalid TCP frame received.
EXCEPTION(S) OCCURRED:
EventStore.ClientAPI.Transport.Tcp.PackageFramingException: Package size is out
of bounds: 1347703880 (max: 67108864).
at EventStore.ClientAPI.Transport.Tcp.LengthPrefixMessageFramer.Parse(ArraySe
gment`1 bytes)
at EventStore.ClientAPI.Transport.Tcp.LengthPrefixMessageFramer.UnFrameData(I
Enumerable`1 data)
at EventStore.ClientAPI.Transport.Tcp.TcpPackageConnection.OnRawDataReceived(
ITcpConnection connection, IEnumerable`1 data)
Can anyone help? Is there any good link for getting started with the event store?
thanks.
Luis