【问题标题】:.Net application cant connect to RabbitMQ on minikube.Net 应用程序无法连接到 minikube 上的 RabbitMQ
【发布时间】:2021-09-21 05:58:36
【问题描述】:

我正在尝试将我的 .Net 应用程序 pod 连接到我在 minikube 中运行的 RabbitMQ pod。我尝试了所有类型的服务,因为它不起作用我尝试直接将 Pod 与其在 Pod 中的 IP 地址连接起来。即使这样,应用程序 pod 也无法连接到 RabbitMQ pod。

这是我遇到的错误

[05:40:31 INF] RabbitMQ Client is trying to connect
[05:40:39 WRN] RabbitMQ Client could not connect after 2.0s (None of the specified endpoints were reachable)
RabbitMQ.Client.Exceptions.BrokerUnreachableException: None of the specified endpoints were reachable
 ---> System.AggregateException: One or more errors occurred. (Connection failed)
 ---> RabbitMQ.Client.Exceptions.ConnectFailureException: Connection failed
 ---> System.Net.Internals.SocketExceptionFactory+ExtendedSocketException (00000001, 11): Resource temporarily unavailable
   at System.Net.Dns.GetHostEntryOrAddressesCore(String hostName, Boolean justAddresses)
   at System.Net.Dns.<>c.b__27_2(Object s)
   at System.Threading.Tasks.Task`1.InnerInvoke()
   at System.Threading.Tasks.Task.<>c.<.cctor>b__277_0(Object obj)
   at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)

虽然我可以通过使用 nordport 服务时登录到 rabbitmq 管理仪表板。

这是我的 pod 规格

spec:
  containers:
    - name: rabbitmq
      image: rabbitmq:3-management-alpine
      # image name : tag
      ports:
        - containerPort: 5672
          name: amqp
        - containerPort: 15672
          name: http
      env:
        - name: RABBITMQ_DEFAULT_VHOST
          value: /
        - name: RABBITMQ_DEFAULT_USER
          value: dev
        - name: RABBITMQ_DEFAULT_PASS
          value: dev     

编辑 我在这里添加了我的服务文件

apiVersion: v1
kind: Service
metadata:
  name: rabbitmq-service
  labels:
    name: rabbitmq-service
    app: myapp
spec:
  type: ClusterIP
  clusterIP: None
  ports:
    - name: amqp
      protocol: TCP
      port: 5672
  selector:
    name: rabbitmq-pod
    app: myapp

【问题讨论】:

  • 建议的解决方案here 是否可以帮助您解决问题?
  • @Ashish 我试过了,但没用。我正在通过 configmap 用更新的值替换构建的 appsettings.json,并且它正在 .net 应用程序 pod 中接收
  • @PamudithaNavaratne 请分享您的service.yaml 和更多详细信息,您的.net 应用程序位于:在 kuberenetes 集群中还是在外部?以及您指定的连接字符串到底如何?

标签: .net kubernetes rabbitmq minikube


【解决方案1】:

问题在于 appsettings.json;尽管我将配置映射中的连接字符串提交到 appsettings.json,但应用程序正在从 apsetting.Development.json 获取配置。

【讨论】:

    猜你喜欢
    • 2016-02-23
    • 2020-03-07
    • 2022-12-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-03-19
    • 1970-01-01
    • 2021-01-03
    相关资源
    最近更新 更多