Giter Site home page Giter Site logo

Comments (12)

evgenirusev avatar evgenirusev commented on August 12, 2024 38

This means that the app can't connect to Rabbit AMQP api, which should be running on localhost:5672.
I had the same issue when I ran the projects with Docker. My solution was to change "hostnames" in appsettings.json, from "localhost" to "host.docker.internal".

from dnc-dshop.

stefan27dk avatar stefan27dk commented on August 12, 2024 3

Thanks @evgenirusev - I was trying to get the RabitMq "Hello World" tutorial to work and could not figure out why is it not working.

This is what worked for me:

  1. In Docker Terminal "Client" to make new Image - docker run -d --hostname my-rabit --name ecomm-rabbit -p 15672:15672 -p 5672:5672 rabbitmq:3

  2. Than I copied the IP which is "192.168.99.100:15672" with the port :15672 and used that in the RabitMq as hostname - "Copied from the docker kitematic app"

  3. In RabitMQ Console App Send And Receive - factory.HostName = "192.168.99.100";

  4. In RabitMQ Console App Send And Receive - factory.Port = AmqpTcpEndpoint.UseDefaultPort;

from dnc-dshop.

Cassia-Assis avatar Cassia-Assis commented on August 12, 2024 1

Hello! I didn't understand how you solved the problem, could you please tell me how?

from dnc-dshop.

NiuziyuanPy avatar NiuziyuanPy commented on August 12, 2024

You solved it. I also met this mistake

from dnc-dshop.

dowhilecode avatar dowhilecode commented on August 12, 2024

thanks @evgenirusev for me "host.docker.internal" worked.

In my situation I have a docker desktop running with linux container and rabbitmq:3-management on it, then I created a dotnet core webapi with VS 20219.

Now when I am running the code it is working

  1. "localhost" on IIS Express
  2. "localhost" on Docker build from Visual Studio
  3. "host.docker.internal" on Docker build from Visual Studio

But not working in this scenario
"host.docker.internal" on Docker with docker build command
docker build -t mytagImage .
docker run -d -p 7384:80 mytagImage

from dnc-dshop.

dowhilecode avatar dowhilecode commented on August 12, 2024

I have also faced the issue you can check this issue and resolution

Happy Coding!

from dnc-dshop.

Gourav636 avatar Gourav636 commented on August 12, 2024

Hi, I created a small application using .netcore and rabbitmq and created the image in docker for both of them using below docker-compose code -

version: '3'
services:
rabbitmq:
container_name: rabbitmq
hostname: "rabbitmq"
image: rabbitmq:3-management
ports:
- "5672:5672"
- "15672:15672"
volumes:
- rabbitmq:/rabbitmq
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:15672"]
interval: 30s
timeout: 10s
retries: 5

isp_hub:
depends_on:
- rabbitmq
build:
context: .
dockerfile: Dockerfile
ports:
- "9090:80"

volumes:
rabbitmq:

after running the cmd docker-compose up the image is created and container is started and i am using Jmeter client to hit the container .net code is working but while trying to pass the data in queue getting below exception -

"log":"info: Microsoft.Hosting.Lifetime[0]\r\n","stream":"stdout","time":"2022-04-04T08:25:22.6109672Z"}
{"log":" Application is shutting down...\r\n","stream":"stdout","time":"2022-04-04T08:25:22.6109672Z"}
{"log":"info: Microsoft.Hosting.Lifetime[0]\r\n","stream":"stdout","time":"2022-04-04T08:25:38.4488984Z"}
{"log":" Now listening on: http://[::]:80\r\n","stream":"stdout","time":"2022-04-04T08:25:38.4488984Z"}
{"log":"info: Microsoft.Hosting.Lifetime[0]\r\n","stream":"stdout","time":"2022-04-04T08:25:38.4498991Z"}
{"log":" Application started. Press Ctrl+C to shut down.\r\n","stream":"stdout","time":"2022-04-04T08:25:38.4498991Z"}
{"log":"info: Microsoft.Hosting.Lifetime[0]\r\n","stream":"stdout","time":"2022-04-04T08:25:38.4498991Z"}
{"log":" Hosting environment: Production\r\n","stream":"stdout","time":"2022-04-04T08:25:38.4498991Z"}
{"log":"info: Microsoft.Hosting.Lifetime[0]\r\n","stream":"stdout","time":"2022-04-04T08:25:38.4498991Z"}
{"log":" Content root path: C:\app\r\n","stream":"stdout","time":"2022-04-04T08:25:38.4498991Z"}
{"log":"fail: Microsoft.AspNetCore.SignalR.Internal.DefaultHubDispatcher[8]\r\n","stream":"stdout","time":"2022-04-04T08:26:55.7889752Z"}
{"log":" Failed to invoke hub method 'SendToMessageBroker'.\r\n","stream":"stdout","time":"2022-04-04T08:26:55.7889752Z"}
{"log":" RabbitMQ.Client.Exceptions.BrokerUnreachableException: None of the specified endpoints were reachable\r\n","stream":"stdout","time":"2022-04-04T08:26:55.7889752Z"}
{"log":" ---\u003e System.AggregateException: One or more errors occurred. (Connection failed)\r\n","stream":"stdout","time":"2022-04-04T08:26:55.7889752Z"}
{"log":" ---\u003e RabbitMQ.Client.Exceptions.ConnectFailureException: Connection failed\r\n","stream":"stdout","time":"2022-04-04T08:26:55.7889752Z"}
{"log":" ---\u003e System.Net.Sockets.SocketException (10061): No connection could be made because the target machine actively refused it.\r\n","stream":"stdout","time":"2022-04-04T08:26:55.7889752Z"}
{"log":" at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ThrowException(SocketError error, CancellationToken cancellationToken)\r\n","stream":"stdout","time":"2022-04-04T08:26:55.7889752Z"}
{"log":" at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.System.Threading.Tasks.Sources.IValueTaskSource.GetResult(Int16 token)\r\n","stream":"stdout","time":"2022-04-04T08:26:55.7889752Z"}
{"log":" at System.Threading.Tasks.ValueTask.ValueTaskSourceAsTask.\u003c\u003ec.\u003c.cctor\u003eb__4_0(Object state)\r\n","stream":"stdout","time":"2022-04-04T08:26:55.7889752Z"}
{"log":" --- End of stack trace from previous location ---\r\n","stream":"stdout","time":"2022-04-04T08:26:55.7889752Z"}
{"log":" at RabbitMQ.Client.Impl.TcpClientAdapter.ConnectAsync(String host, Int32 port)\r\n","stream":"stdout","time":"2022-04-04T08:26:55.7889752Z"}
{"log":" at RabbitMQ.Client.Impl.TaskExtensions.TimeoutAfter(Task task, TimeSpan timeout)\r\n","stream":"stdout","time":"2022-04-04T08:26:55.7889752Z"}
{"log":" at RabbitMQ.Client.Impl.SocketFrameHandler.ConnectOrFail(ITcpClient socket, AmqpTcpEndpoint endpoint, TimeSpan timeout)\r\n","stream":"stdout","time":"2022-04-04T08:26:55.7889752Z"}
{"log":" --- End of inner exception stack trace ---\r\n","stream":"stdout","time":"2022-04-04T08:26:55.7889752Z"}
{"log":" at RabbitMQ.Client.Impl.SocketFrameHandler.ConnectOrFail(ITcpClient socket, AmqpTcpEndpoint endpoint, TimeSpan timeout)\r\n","stream":"stdout","time":"2022-04-04T08:26:55.7889752Z"}
{"log":" at RabbitMQ.Client.Impl.SocketFrameHandler.ConnectUsingAddressFamily(AmqpTcpEndpoint endpoint, Func2 socketFactory, TimeSpan timeout, AddressFamily family)\r\n","stream":"stdout","time":"2022-04-04T08:26:55.7889752Z"} {"log":" at RabbitMQ.Client.Impl.SocketFrameHandler.ConnectUsingIPv4(AmqpTcpEndpoint endpoint, Func2 socketFactory, TimeSpan timeout)\r\n","stream":"stdout","time":"2022-04-04T08:26:55.7889752Z"}
{"log":" at RabbitMQ.Client.Impl.SocketFrameHandler..ctor(AmqpTcpEndpoint endpoint, Func2 socketFactory, TimeSpan connectionTimeout, TimeSpan readTimeout, TimeSpan writeTimeout)\r\n","stream":"stdout","time":"2022-04-04T08:26:55.7889752Z"} {"log":" at RabbitMQ.Client.Framing.Impl.IProtocolExtensions.CreateFrameHandler(IProtocol protocol, AmqpTcpEndpoint endpoint, Func2 socketFactory, TimeSpan connectionTimeout, TimeSpan readTimeout, TimeSpan writeTimeout)\r\n","stream":"stdout","time":"2022-04-04T08:26:55.7889752Z"}
{"log":" at RabbitMQ.Client.ConnectionFactory.CreateFrameHandler(AmqpTcpEndpoint endpoint)\r\n","stream":"stdout","time":"2022-04-04T08:26:55.7889752Z"}
{"log":" at RabbitMQ.Client.EndpointResolverExtensions.SelectOne[T](IEndpointResolver resolver, Func2 selector)\r\n","stream":"stdout","time":"2022-04-04T08:26:55.7889752Z"} {"log":" --- End of inner exception stack trace ---\r\n","stream":"stdout","time":"2022-04-04T08:26:55.7889752Z"} {"log":" at RabbitMQ.Client.EndpointResolverExtensions.SelectOne[T](IEndpointResolver resolver, Func2 selector)\r\n","stream":"stdout","time":"2022-04-04T08:26:55.7889752Z"}
{"log":" at RabbitMQ.Client.Framing.Impl.AutorecoveringConnection.Init(IEndpointResolver endpoints)\r\n","stream":"stdout","time":"2022-04-04T08:26:55.7889752Z"}
{"log":" at RabbitMQ.Client.ConnectionFactory.CreateConnection(IEndpointResolver endpointResolver, String clientProvidedName)\r\n","stream":"stdout","time":"2022-04-04T08:26:55.7889752Z"}
{"log":" --- End of inner exception stack trace ---\r\n","stream":"stdout","time":"2022-04-04T08:26:55.7889752Z"}
{"log":" at RabbitMQ.Client.ConnectionFactory.CreateConnection(IEndpointResolver endpointResolver, String clientProvidedName)\r\n","stream":"stdout","time":"2022-04-04T08:26:55.7889752Z"}
{"log":" at RabbitMQ.Client.ConnectionFactory.CreateConnection(String clientProvidedName)\r\n","stream":"stdout","time":"2022-04-04T08:26:55.7889752Z"}
{"log":" at RabbitMQ.Client.ConnectionFactory.CreateConnection()\r\n","stream":"stdout","time":"2022-04-04T08:26:55.7889752Z"}
{"log":" at ISP_Hub.HubConfig.CenterHub.SendToMessageBroker(String requestData) in C:\src\ISP_Hub\HubConfig\CenterHub.cs:line 38\r\n","stream":"stdout","time":"2022-04-04T08:26:55.7889752Z"}
{"log":" at Microsoft.Extensions.Internal.ObjectMethodExecutor.\u003c\u003ec__DisplayClass33_0.\u003cWrapVoidMethod\u003eb__0(Object target, Object[] parameters)\r\n","stream":"stdout","time":"2022-04-04T08:26:55.7889752Z"}
{"log":" at Microsoft.AspNetCore.SignalR.Internal.DefaultHubDispatcher1.ExecuteMethod(ObjectMethodExecutor methodExecutor, Hub hub, Object[] arguments)\r\n","stream":"stdout","time":"2022-04-04T08:26:55.7889752Z"} {"log":" at Microsoft.AspNetCore.SignalR.Internal.DefaultHubDispatcher1.\u003c\u003ec__DisplayClass16_0.\u003c\u003cInvoke\u003eg__ExecuteInvocation|0\u003ed.MoveNext()\r\n","stream":"stdout","time":"2022-04-04T08:26:55.7889752Z"}

rabbitmq connection code -

public void SendToMessageBroker(string requestData)
{
var trace = JsonConvert.DeserializeObject(requestData);
// string rabbitMqUrl = "127.0.0.1";
// var factory = new ConnectionFactory() { HostName = "172.24.17.225", Port = 5672 };
//var factory = new ConnectionFactory
//{
// HostName = rabbitMqUrl,
// UserName = "guest",
// Password = "guest",
// Port = AmqpTcpEndpoint.UseDefaultPort,
// VirtualHost = "/",
// RequestedHeartbeat = new TimeSpan(60),
// Ssl = { ServerName = rabbitMqUrl, Enabled = false }
//};
var factory = new RabbitMQ.Client.ConnectionFactory
{
Uri = new Uri("amqp://guest:guest@localhost:5672/")
};
using var conn = factory.CreateConnection();
using var channel = conn.CreateModel();
RabbitMQPublisher.Publish(channel, trace);
Clients.All.SendAsync("test");
channel.Close();
conn.Close();
Debug.WriteLine("Show Message: " + requestData);

        //}
        //catch (Exception)
        //{
        //    Debug.WriteLine(count);
        //    count++;
        //}
    }

i am new to docker . please help me to understand the issue and how to resolve it

from dnc-dshop.

Bakhtiyariha avatar Bakhtiyariha commented on August 12, 2024

run rabbitmq on docker.
docker run -p 5672:5672 rabbitmq

from dnc-dshop.

CardinPatson avatar CardinPatson commented on August 12, 2024

This means that the app can't connect to Rabbit AMQP api, which should be running on localhost:5672. I had the same issue when I ran the projects with Docker. My solution was to change "hostnames" in appsettings.json, from "localhost" to "host.docker.internal".

Facing the same issues, this solves my problems for persistent connection

from dnc-dshop.

UgurSambaPos avatar UgurSambaPos commented on August 12, 2024

evgenirusev 's solution works ! thank you Evgeni Rusev

from dnc-dshop.

BirajMainali avatar BirajMainali commented on August 12, 2024

This means that the app can't connect to Rabbit AMQP api, which should be running on localhost:5672. I had the same issue when I ran the projects with Docker. My solution was to change "hostnames" in appsettings.json, from "localhost" to "host.docker.internal".

It works

from dnc-dshop.

Related Issues (12)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.