"Package size is out of bounds" exception

Hello!

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.

Thank you very much!

That sounds like you tried putting a huge object 1gb as an event. This happened in client code or was reported in server?

Hello Greg,

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”:

let! eventsSlice = conn.ReadStreamEventsForwardAsync(streamId, 1, Int32.MaxValue, false) |> Async.AwaitTask

Which doesn’t make much sense to me right now. So this begs the following questions:

  1. 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).

  2. 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
}

Thanks!

It might be using an old client api?

Hi James,

I grabbed the nuget package, (version 2.0.2.0), so… I don’t think so.

Thank you!

The code says it works on 2.0.1 not 2.0.2

ok so it happens in the client (from our perspective). Try grabbing 2.0.1 which is what the code says its tested against and see if it works.

Cheers,

Greg

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.

Thanks a lot for helping out,

Jacobo

Can you put up the code on Github or similar and I’ll try to reproduce locally

Cheers,

James

Sure! I haven’t done much and there are probably some things wrong, but here it is: https://github.com/jacobopolavieja/hellothere

Thank you very much,

Jacobo

Could it be that you are trying to do HTTP requests to TCP port?

    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

What a simple and stupid mistake… That was it, working great now finally.

Thank you very much guys for taking the time to dig into it, I really appreciate it.

Cheers!