# Traefik Ingress for Rabbitmq AMQP

**URL:** <https://community.traefik.io/t/traefik-ingress-for-rabbitmq-amqp/19899>\
**Category:** Traefik v2\
**Tags:** kubernetes-ingress\
**Created:** [September 20, 2023, 7:35am UTC](https://community.traefik.io/t/traefik-ingress-for-rabbitmq-amqp/19899 "2023-09-20T07:35:11Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![placzykowski](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/placzykowski/32/7596_2.png) [@placzykowski](https://community.traefik.io/u/placzykowski)\
**Post date:** [September 20, 2023, 7:35am UTC](https://community.traefik.io/t/traefik-ingress-for-rabbitmq-amqp/19899/1 "2023-09-20T07:35:11Z")

</div>

Hello,  
I am trying to create ingressRoute/ingressRouteTCP for my rabbit's AMQP port 5672.

This is setup of my service made with rabbitmq-operator:

```auto
spec:
  ports:
    - name: management
      protocol: TCP
      appProtocol: http
      port: 15672
      targetPort: 15672
    - name: amqps
      protocol: TCP
      appProtocol: amqps
      port: 5671
      targetPort: 5671
    - name: management-tls
      protocol: TCP
      appProtocol: https
      port: 15671
      targetPort: 15671
    - name: prometheus-tls
      protocol: TCP
      appProtocol: prometheus.io/metric-tls
      port: 15691
      targetPort: 15691
    - name: amqp
      protocol: TCP
      appProtocol: amqp
      port: 5672
      targetPort: 5672
  selector:
    app.kubernetes.io/name: rabbitmq
  clusterIP: 10.233.8.40
  clusterIPs:
    - 10.233.8.40
  type: ClusterIP
  sessionAffinity: None
  ipFamilies:
    - IPv4
  ipFamilyPolicy: SingleStack

```

And this is setup of my ingressRouteTCP:

```auto
apiVersion: traefik.io/v1alpha1
kind: IngressRouteTCP
metadata:
  name: rabbitmq-amqp
  namespace: spark-dev-sparrow
spec:
  entryPoints:
    - amqp
  routes:
    - match: HostSNI(`rabbitmq-amqp.example.com`)
      services:
        - name: rabbitmq
          port: 5672

```

It don't work for me at all while I am trying to connect via Queue explorer. This is an error:

````auto
Cannot read queues from machine Sparrow - rabbitmq-amqp.example.com (RabbitMQ).

StackTrace: 
System.ApplicationException: Could not load machine overview: Unable to connect to the remote server ---> System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond IPIPIPIP
   at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
   at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception)
   --- End of inner exception stack trace ---
   at System.Net.HttpWebRequest.GetResponse()
   at EasyNetQ.Management.Client.HttpWebRequestExtensions.GetHttpResponse(HttpWebRequest request)
   at EasyNetQ.Management.Client.ManagementClient.Get[T](String path, Object[] queryObjects)
   at EasyNetQ.Management.Client.ManagementClient.GetOverview(GetLengthsCriteria lengthsCriteria, GetRatesCriteria ratesCriteria)
   at Cogin.RabbitMQ.Services.RMQMachineLoader.GetOverview(ManagementClient client, RMQLoadedMachine prevLoadedMachine)
   --- End of inner exception stack trace ---
   at Cogin.RabbitMQ.Services.RMQMachineLoader.GetOverview(ManagementClient client, RMQLoadedMachine prevLoadedMachine)
   at Cogin.RabbitMQ.Services.RMQMachineLoader.LoadMachine(ManagementClient client, IWorker worker, RMQCountMode countMode)
   at Cogin.RabbitMQ.Services.RMQBrokerService.LoadTreeItem(IWorker worker, TreeItem treeItem, Boolean showNonWritableQueues, Boolean isAutoRefresh, QueueDataInfo selectedQueue)
   at ev.b.g(IWorker A_0)
   at System.Threading.Tasks.Task.Execute()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at fc.a.d()

Version: QueueExplorer Standard v5.0.25
.Net Framework Version: 4.8.0
OS: Windows 10```
````

---

<div class="post-metadata">

**Author:** ![bluepuma77](https://avatars.discourse-cdn.com/v4/letter/b/a9adbd/32.png) [@bluepuma77](https://community.traefik.io/u/bluepuma77)\
**Post date:** [September 20, 2023, 7:43am UTC](https://community.traefik.io/t/traefik-ingress-for-rabbitmq-amqp/19899/2 "2023-09-20T07:43:43Z")

</div>

There seems to be a backtick missing:

> [@placzykowski](#):
>
> `match: HostSNI(`rabbitmq-amqp.example.com)`

No connection seems like a basic networking problem. Does the DNS have the correct IP, which port is used, is the port open?

---

<div class="post-metadata">

**Author:** ![placzykowski](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/placzykowski/32/7596_2.png) [@placzykowski](https://community.traefik.io/u/placzykowski)\
**Post date:** [September 20, 2023, 7:52am UTC](https://community.traefik.io/t/traefik-ingress-for-rabbitmq-amqp/19899/3 "2023-09-20T07:52:35Z")

</div>

It's my typo during changing the URL when I was writing a post.  
Everything is open and it shoudn't couse any problems

---

<div class="post-metadata">

**Author:** ![bluepuma77](https://avatars.discourse-cdn.com/v4/letter/b/a9adbd/32.png) [@bluepuma77](https://community.traefik.io/u/bluepuma77)\
**Post date:** [September 20, 2023, 7:59am UTC](https://community.traefik.io/t/traefik-ingress-for-rabbitmq-amqp/19899/4 "2023-09-20T07:59:04Z")

</div>

Connection can’t be established. So it’s a mismatch of IP/port or those are not listening or not accessible.

I find it strange that you get the error with `HttpWebRequest`, you should check which protocol/port the client is trying to use.

---

<div class="post-metadata">

**Author:** ![placzykowski](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/placzykowski/32/7596_2.png) [@placzykowski](https://community.traefik.io/u/placzykowski)\
**Post date:** [September 20, 2023, 2:01pm UTC](https://community.traefik.io/t/traefik-ingress-for-rabbitmq-amqp/19899/5 "2023-09-20T14:01:22Z")

</div>

![image](https://us1.discourse-cdn.com/flex020/uploads/containo/original/2X/f/f2e3330fea78e58ee281a13f8ddbbc3615c9597a.png)

This is setup of the client

---

<div class="post-metadata">

**Author:** ![bluepuma77](https://avatars.discourse-cdn.com/v4/letter/b/a9adbd/32.png) [@bluepuma77](https://community.traefik.io/u/bluepuma77)\
**Post date:** [September 20, 2023, 2:52pm UTC](https://community.traefik.io/t/traefik-ingress-for-rabbitmq-amqp/19899/6 "2023-09-20T14:52:18Z")

</div>

Well, it seems it uses two ports, so you should enable both.

---

<div class="post-metadata">

**Author:** ![placzykowski](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/placzykowski/32/7596_2.png) [@placzykowski](https://community.traefik.io/u/placzykowski)\
**Post date:** [September 21, 2023, 6:55am UTC](https://community.traefik.io/t/traefik-ingress-for-rabbitmq-amqp/19899/7 "2023-09-21T06:55:06Z")

</div>

```auto
spec:
  entryPoints:
    - web
  routes:
    - kind: Rule
      match: Host(`rabbitmq-sparrow.example.com`)
      middlewares:
        - name: redirect-https
      services:
        - name: rabbitmq
          port: 15672

```

Second one works perfectly. That's why I didn't mention that

---

<div class="post-metadata">

**Author:** ![bluepuma77](https://avatars.discourse-cdn.com/v4/letter/b/a9adbd/32.png) [@bluepuma77](https://community.traefik.io/u/bluepuma77)\
**Post date:** [September 21, 2023, 7:02am UTC](https://community.traefik.io/t/traefik-ingress-for-rabbitmq-amqp/19899/8 "2023-09-21T07:02:38Z")

</div>

You complain about your tool not being able to connect. It uses two ports for potentially two different protocols.

This is what ChatGPT says:

> Port 5672: AMQP 0-9-1 protocol, used for client-broker communication  
> Port 15672: HTTP/HTTPS protocol, used for web management interface

Your `HttpWebRequest` error indicates it’s rather the second port, that has an issue.

---

<div class="post-metadata">

**Author:** ![placzykowski](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/placzykowski/32/7596_2.png) [@placzykowski](https://community.traefik.io/u/placzykowski)\
**Post date:** [September 21, 2023, 7:39am UTC](https://community.traefik.io/t/traefik-ingress-for-rabbitmq-amqp/19899/9 "2023-09-21T07:39:08Z")

</div>

Well I can tell that it works, beacuse via this URL I can login to the rabbita dashboard.

---

<div class="post-metadata">

**Author:** ![bluepuma77](https://avatars.discourse-cdn.com/v4/letter/b/a9adbd/32.png) [@bluepuma77](https://community.traefik.io/u/bluepuma77)\
**Post date:** [September 21, 2023, 8:07am UTC](https://community.traefik.io/t/traefik-ingress-for-rabbitmq-amqp/19899/10 "2023-09-21T08:07:49Z")

</div>

Did the original `SocketException` provide IP and port? Does that match with Traefik host?

---

<div class="post-metadata">

**Author:** ![placzykowski](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/placzykowski/32/7596_2.png) [@placzykowski](https://community.traefik.io/u/placzykowski)\
**Post date:** [September 21, 2023, 8:11am UTC](https://community.traefik.io/t/traefik-ingress-for-rabbitmq-amqp/19899/11 "2023-09-21T08:11:56Z")

</div>

Yes it match. I am talking with networking guys do we have open port 5672 on 100%

---

<div class="post-metadata">

**Author:** ![placzykowski](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/placzykowski/32/7596_2.png) [@placzykowski](https://community.traefik.io/u/placzykowski)\
**Post date:** [September 21, 2023, 8:32am UTC](https://community.traefik.io/t/traefik-ingress-for-rabbitmq-amqp/19899/12 "2023-09-21T08:32:19Z")

</div>

I found something. Ofcourse 15672 for management changes to 80, beacuse of ingressRoute.  
This is new error:

```auto
Cannot read queues from machine Sparrow - rabbitmq-amqp-sparrow.example.com (RabbitMQ).

StackTrace: 
System.ApplicationException: Could not load machine overview: Unexpected Status Code: 401 Unauthorized ---> EasyNetQ.Management.Client.UnexpectedHttpStatusCodeException: Unexpected Status Code: 401 Unauthorized
   at EasyNetQ.Management.Client.ManagementClient.Get[T](String path, Object[] queryObjects)
   at EasyNetQ.Management.Client.ManagementClient.GetOverview(GetLengthsCriteria lengthsCriteria, GetRatesCriteria ratesCriteria)
   at Cogin.RabbitMQ.Services.RMQMachineLoader.GetOverview(ManagementClient client, RMQLoadedMachine prevLoadedMachine)
   --- End of inner exception stack trace ---
   at Cogin.RabbitMQ.Services.RMQMachineLoader.GetOverview(ManagementClient client, RMQLoadedMachine prevLoadedMachine)
   at Cogin.RabbitMQ.Services.RMQMachineLoader.LoadMachine(ManagementClient client, IWorker worker, RMQCountMode countMode)
   at eq.b.d(IWorker A_0)
   at System.Threading.Tasks.Task.Execute()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at fc.a.d()

Version: QueueExplorer Standard v5.0.25
.Net Framework Version: 4.8.0
OS: Windows 10

```
