I’m pulling in a large dataset as a test (multiple GB). After a period of time, I am seeing a RetriesLimitReachedException in my client, and a HEARTBEAT TIMEOUT message on the server.
My code:
var file =
new System.IO.StreamReader(@“c:\users\jrivers\desktop\tsu.txt”);
string line;
var connectionSettings = ConnectionSettings.Create();
connectionSettings.SetHeartbeatTimeout(new TimeSpan(0, 3, 0));
connectionSettings.KeepReconnecting();
connectionSettings.KeepRetrying();
var connection = EventStoreConnection.Create(new IPEndPoint(IPAddress.Loopback, 1113));
connection.Connect();
var SerializerSettings = new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.None };
var eventBatch = new List();
var allTasks = new List();
byte[] eventmetadata = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(new { Something = “Nothing” }, SerializerSettings));
while ((line = file.ReadLine()) != null)
{
var strings = line.Split(’,’);
var tsuLine = new
{
update_id = Convert.ToInt64(strings[0]),
station_id = Convert.ToInt64(strings[1]),
entity_id = Convert.ToInt64(strings[2]),
created_date = DateTime.Parse(strings[6])
};
byte[] eventdata = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(new { Time = DateTime.Now, Event = tsuline }, SerializerSettings));
eventBatch.Add(new EventData(Guid.NewGuid(), “trialevent”, true, eventdata, eventmetadata));
if (eventBatch.Count >= 20)
{
var task = connection.AppendToStreamAsync(“trialstream”, ExpectedVersion.Any, eventBatch);
allTasks.Add(task);
eventBatch = new List();
}
}
file.Close();
Task.WaitAll(allTasks.ToArray());
``
My questions:
-
Why do you think I’m getting this error? Shouldn’t KeepRetrying solve this?
-
Is this something I should need to guard against in production code? How do I guard this (I’m not sure if this is a connection failure that requires a rebuild of the connection, or if I just need to re-run the task, or what)?
-
Is there some other way I’m failing here?
Thanks,
Josh