As my first little project to get to work with Event Sourcing, I’m trying to get make a simple Web API program, based on Lev Gorodinski’s DDDInventoryItem.
When I try to make a POST request to the iventoryitem controller passing in a JSON with a name, I get the following exception:
Exception:Thrown: “Package size is out of bounds: 1347703880 (max: 67108864).” (EventStore.ClientAPI.Transport.Tcp.PackageFramingException)
A EventStore.ClientAPI.Transport.Tcp.PackageFramingException was thrown: “Package size is out of bounds: 1347703880 (max: 67108864).”
Any idea where can this come from? As this is the only F# project publicly available making use of Event Sourcing, I really don’t know where else to look, and I haven’t found much on the EventStore site. If anybody knows of other F# projects making use of Event Sourcing it owuld be great too… but let’s see if there’s a fix for this error.
It happened in the server. The exception is thrown when trying to execute the command. In fact, I’m just sending the posts requests with Fiddler.
After several breakpoints trying to figure out where it crashed, I see it is failing when trying to load events before executing the command. Specifically on line 22 of the EventStore “handling file”:
Which doesn’t make much sense to me right now. So this begs the following questions:
As this is a Create command, should I be loading previous events (knowing there will never be one)? (I know the intent of the original author was to have a uniform interface to handle any command).
Is trying to read from a non-existent streamId causing the exception?
Here’s the function calling the load funcion of the EventStore file, in case it’s of help:
/// Creates a persistent, async command handler for an aggregate given load and commit functions.
let makeHandler (aggregate:Aggregate<'TState, 'TCommand, 'TEvent>) (load:System.Type * Id -> Async, commit:Id * int -> obj -> Async) =
fun (id,version) command -> async {
let! events = load (typeof<'TEvent>,id)
let events = events |> Seq.cast :> 'TEvent seq
let state = Seq.fold aggregate.apply aggregate.zero events
let event = aggregate.exec state command
match event with
> Choice1Of2 event ->
let! _ = event |> commit (id,version)
return Choice1Of2 ()
> Choice2Of2 errors ->
return errors |> Choice2Of2
}
Oh, I was trully smart with the client question… sorry!
Tried with 2.0.1, still the same error. Is there anything I can do to track this down in an easier manner? Just in case… I’m using VS2013 with the F# Web API 2 template.
static member EventStore = lazy(
let endPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("127.0.0.1"), 2113)
EventStore.conn endPoint)
This is the http port. Use 1113 by default for tcp client