Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullReferenceException - when using Akka.Net v1.5.12 and Akka.Streams.Amqp.RabbitMq v1.5.8 #1659

Closed
marekkardos opened this issue Aug 7, 2023 · 3 comments · Fixed by #1891
Labels
rabbitmq Issues affecting RabbitMQ / AMQP connectors

Comments

@marekkardos
Copy link

Version Information
Akka.Net v1.5.12
Akka.Hosting v1.5.12
Akka.Streams v1.5.12
Akka.Streams.Amqp.RabbitMq v1.5.8
Akka.Cluster.Hosting v1.5.12

Describe the bug
Both Producer and Consumer of the Sample are throwing NullReferenceException.

To Reproduce
Steps to reproduce the behavior:

  1. Checkout master from
    https://github.com/petabridge/akkadotnet-code-samples/tree/master/src/reliability/rabbitmq-backpressure

  2. Update NugetDependencies in the project: ReliableRabbitMQ.Shared

<PropertyGroup>
    <TargetFramework>$(NetRuntime)</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
    <PackageReference Include="Akka" Version="1.5.12" />
    <PackageReference Include="Akka.Hosting" Version="1.5.12" />
    <PackageReference Include="Akka.Streams" Version="1.5.12" />
    <PackageReference Include="Akka.Streams.Amqp.RabbitMq" Version="1.5.8" />
    <PackageReference Include="Akka.Cluster.Hosting" Version="1.5.12" />
</ItemGroup>
  1. Run both ReliableRabbitMQ.Consumer and ReliableRabbitMQ.Producer

  2. See the error in console.

Expected behavior
Both ReliableRabbitMQ.Consumer and ReliableRabbitMQ.Producer are working without an error.

Actual behavior
Both ReliableRabbitMQ.Consumer and ReliableRabbitMQ.Producer console apps are throwing NullReferenceException.

-------------------------------- Producer --------------------------------
[ERROR][08. 07. 2023 12:36:44.268Z][Thread 0014][[akka://RabbitMQProducer/user/amqp-producer/StreamSupervisor-1/Flow-1-2-AmqpSink#881794866]] Error during PreStart in [AmqpSink]
Cause: RabbitMQ.Client.Exceptions.BrokerUnreachableException: None of the specified endpoints were reachable
---> System.AggregateException: One or more errors occurred. (Object reference not set to an instance of an object.)
---> System.NullReferenceException: Object reference not set to an instance of an object.
at RabbitMQ.Client.Impl.SocketFrameHandler..ctor(AmqpTcpEndpoint endpoint, Func2 socketFactory, TimeSpan connectionTimeout, TimeSpan readTimeout, TimeSpan writeTimeout) at RabbitMQ.Client.ConnectionFactory.CreateFrameHandler(AmqpTcpEndpoint endpoint) at RabbitMQ.Client.EndpointResolverExtensions.SelectOne[T](IEndpointResolver resolver, Func2 selector)
--- End of inner exception stack trace ---
at RabbitMQ.Client.EndpointResolverExtensions.SelectOne[T](IEndpointResolver resolver, Func2 selector) at RabbitMQ.Client.Framing.Impl.AutorecoveringConnection.Init(IEndpointResolver endpoints) at RabbitMQ.Client.ConnectionFactory.CreateConnection(IEndpointResolver endpointResolver, String clientProvidedName) --- End of inner exception stack trace --- at RabbitMQ.Client.ConnectionFactory.CreateConnection(IEndpointResolver endpointResolver, String clientProvidedName) at Akka.Streams.Amqp.RabbitMq.AmqpConnectorLogic.PreStart() --- End of stack trace from previous location --- at Akka.Actor.PipeToSupport.PipeTo(Task taskToPipe, ICanTell recipient, Boolean useConfigureAwait, IActorRef sender, Func1 success, Func`2 failure)
at Akka.Streams.Implementation.Fusing.GraphInterpreter.Init(IMaterializer subMaterializer)

-------------------------------- Consumer --------------------------------
[ERROR][08. 07. 2023 12:36:45.507Z][Thread 0014][[akka://RabbitConsumer/user/amqp-consumer/amqp-consumer/StreamSupervisor-1/Flow-0-0-unknown-operation#844566059]] Error during PreStart in [AmqpSource]
Cause: RabbitMQ.Client.Exceptions.BrokerUnreachableException: None of the specified endpoints were reachable
---> System.AggregateException: One or more errors occurred. (Object reference not set to an instance of an object.)
---> System.NullReferenceException: Object reference not set to an instance of an object.
at RabbitMQ.Client.Impl.SocketFrameHandler..ctor(AmqpTcpEndpoint endpoint, Func2 socketFactory, TimeSpan connectionTimeout, TimeSpan readTimeout, TimeSpan writeTimeout) at RabbitMQ.Client.ConnectionFactory.CreateFrameHandler(AmqpTcpEndpoint endpoint) at RabbitMQ.Client.EndpointResolverExtensions.SelectOne[T](IEndpointResolver resolver, Func2 selector)
--- End of inner exception stack trace ---
at RabbitMQ.Client.EndpointResolverExtensions.SelectOne[T](IEndpointResolver resolver, Func`2 selector)
at RabbitMQ.Client.Framing.Impl.AutorecoveringConnection.Init(IEndpointResolver endpoints)
at RabbitMQ.Client.ConnectionFactory.CreateConnection(IEndpointResolver endpointResolver, String clientProvidedName)
--- End of inner exception stack trace ---
at RabbitMQ.Client.ConnectionFactory.CreateConnection(IEndpointResolver endpointResolver, String clientProvidedName)
at Akka.Streams.Amqp.RabbitMq.AmqpConnectorLogic.PreStart()
at Akka.Streams.Implementation.Fusing.GraphInterpreter.Init(IMaterializer subMaterializer)

Screenshots

Environment
Windows 10 Pro 22H2,
RabbitMQ 3.11.10 on Erlang 25.3 running in Docker,
.NET 6

@marekkardos
Copy link
Author

I've just realized the problem is caused by Akka.Streams.Amqp.RabbitMq v1.5.8,
As I downgraded to Akka.Streams.Amqp.RabbitMq v1.5.7 the problem disapeared.
Now it works fine with the older version.

@Aaronontheweb
Copy link
Member

I've just realized the problem is caused by Akka.Streams.Amqp.RabbitMq v1.5.8, As I downgraded to Akka.Streams.Amqp.RabbitMq v1.5.7 the problem disapeared. Now it works fine with the older version.

Weird, not sure what could be causing that. I'll take a look at the diffs.

@Aaronontheweb Aaronontheweb added the rabbitmq Issues affecting RabbitMQ / AMQP connectors label Mar 23, 2024
@Aaronontheweb
Copy link
Member

Found the problem - this PR introduced a regression in v1.5.8 that can cause this NRE: #1612

Aaronontheweb added a commit to Aaronontheweb/Alpakka that referenced this issue Mar 23, 2024
@Aaronontheweb Aaronontheweb added this to the Alpakka v1.5.19 milestone Mar 23, 2024
Aaronontheweb added a commit that referenced this issue Mar 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rabbitmq Issues affecting RabbitMQ / AMQP connectors
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants