0

Is anyone familiar with Aeron.NET using c#? I'm trying to simply open a connection to a multicast and am not able to do so. I can successfully use netcat to see a transmission to the 'udp' address but it will not connect.

Code

using System;
using System.Threading;
using Adaptive.Aeron.LogBuffer;
using Adaptive.Agrona;
using Adaptive.Agrona.Concurrent;

namespace AeronTest
{
    class Program
    {
        public static void Main()
        {
        // aeron:udp?endpoint=224.9.10.11:12966
        // StreamId: 11


            const string channel = "aeron:udp?endpoint=224.9.10.11:12966";
            const int streamId = 11;

            var buffer = new UnsafeBuffer(new byte[256]);
            var handler = HandlerHelper.ToFragmentHandler(PrintMessage);

            try
            {
                using (var aeron = Adaptive.Aeron.Aeron.Connect())
                using (var publisher = aeron.AddPublication(channel, streamId))
                using (var subscriber = aeron.AddSubscription(channel, streamId))
                {
                    var message = buffer.PutStringWithoutLengthUtf8(0, "Hello World!");

                    publisher.Offer(buffer, 0, message);
                    Console.WriteLine("Message sent...");

                    while (subscriber.Poll(handler, 1) == 0)
                    {
                        Thread.Sleep(10);
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
            finally
            {
                Console.WriteLine("Press any key to continue...");
                Console.ReadKey();
            }
        }

        private static void PrintMessage(IDirectBuffer buffer, int offset, int length, Header header)
        {
            var message = buffer.GetStringWithoutLengthUtf8(offset, length);

            Console.WriteLine($"Received message ({message}) to stream {header.StreamId:D} from session {header.SessionId:x} term id {header.TermId:x} term offset {header.TermOffset:D} ({length:D}@{offset:D})");
        }
    }
}

Error

Adaptive.Aeron.Exceptions.DriverTimeoutException: CnC file not created: C:\Users\user.name\AppData\Local\Temp\aeron-user.name\cnc.dat
   at Adaptive.Aeron.Aeron.Context.WaitForFileMapping(FileInfo cncFile, IEpochClock clock, Int64 deadLineMs)
   at Adaptive.Aeron.Aeron.Context.ConnectToDriver()
   at Adaptive.Aeron.Aeron.Context.Conclude()
   at Adaptive.Aeron.Aeron..ctor(Context ctx)
   at Adaptive.Aeron.Aeron.Connect(Context ctx)
   at Adaptive.Aeron.Aeron.Connect()
   at AeronTest.Program.Main() in C:\Users\user.name\source\repos\AeronTest\AeronTest\Program.cs:line 25
Press any key to continue...

Successful netcat Here you can see using netcat I can successfully transmit a packet to the n/w address

C:\Program Files (x86)\Nmap>ncat -v -u -z -w 3 224.9.10.11 12966

Ncat: Version 7.92 ( https://nmap.org/ncat )
Ncat: Connected to 224.9.10.11:12966.
Ncat: UDP packet sent successfully
Ncat: 1 bytes sent, 0 bytes received in 2.03 seconds.

thank you

MX313
  • 129
  • 1
  • 9
  • Have you stepped into the code to see why the CnC file is not being created? Normally this is created in the `Context.Conclude()` method which is called by the `Aeron.ctor()`. – Slugart Aug 23 '22 at 01:11
  • yes it just fails on the ```using (var aeron = Adaptive.Aeron.Aeron.Connect())``` attempt. I created the directory and even an empty cnc.dat file incase it was a writing permission thing but no avail – MX313 Aug 23 '22 at 12:25
  • Could you include your .csproj file? – Slugart Aug 25 '22 at 00:48
  • You mention in this issue (https://github.com/AdaptiveConsulting/Aeron.NET/issues/119) that the driver folder is not creaetd when you install the nuget package. That is probably the root cause. Which version of the nuget package are you using? Have you tried re-referencing it in another blank project? Have you checked the contents of the package in the packages folder? – Slugart Aug 25 '22 at 00:50
  • I'm using the latest version and have tried it in empty new projects as well. I am hoping my github question gets answered. Thank you – MX313 Aug 29 '22 at 16:28

0 Answers0