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

Unable connect nats with ingress #84

Open
kuccilim opened this issue Feb 2, 2021 · 0 comments
Open

Unable connect nats with ingress #84

kuccilim opened this issue Feb 2, 2021 · 0 comments

Comments

@kuccilim
Copy link

kuccilim commented Feb 2, 2021

I was successful connect it with kubectl port-forward svc/example-nats 4222:4222, but how to expose it with nginx-ingress?

apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: kubernetes-ingress
  annotations:
    kubernetes.io/ingress.class: nginx
spec:
  rules:
    - host: client.test-stan.xyz
      http:
        paths:
          - backend:
              serviceName: example-nats
              servicePort: 4222

Code:

import nats from "node-nats-streaming";

const stan = nats.connect("example-stan", "abc", {
  // url: "http://localhost:4222", // successful connected
  url: "nats://client.test-stan.xyz:4222", // failed
});

stan.on("connect", () => {
  console.log("Publisher connected to NATS");

  const data = 'hello world!';

  stan.publish("nats:created", data, () => {
    console.log("Event published");
  });
});
@kuccilim kuccilim changed the title Unable to connect with stan with port-forwarding. Unable connect nats with ingress Feb 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant