kubemq-io / kubemq-node

MIT License
18 stars 8 forks source link

Connection URL while testing with minikube #6

Closed dilipkumar2k6 closed 4 years ago

dilipkumar2k6 commented 4 years ago

While testing on local, what should be a connection URL? I have installed kubemq on minikube. Do I need to use minikube ip or localhost?

I am trying to run the given sample code to publish the message but it seems like grpc connection is failing. Following is the sample code.

const kubemq = require("kubemq-nodejs");

(async () => {
  let channelName = "queue";
  let kubemqAdd = "localhost:50000";
  let message_queue = new kubemq.MessageQueue(
    kubemqAdd,
    channelName,
    "transaction"
  );
  const message1 = { hello: "I am test message" };
  let bytes = kubemq.stringToByte("TestBody");

  let tags = [];
  tags["key3"] = "value3";
  tags["key2"] = "value2";

  let message = new kubemq.Message(JSON.stringify(message1), bytes, tags);

  const messageQueueResponse = await message_queue.sendQueueMessage(message);
  console.log(
    `finished sending message ${message} messages response ${messageQueueResponse}`
  );
})();

Following is error

Error: Error: 14 UNAVAILABLE: failed to connect to all addresses
eitam-ring commented 4 years ago

Hi @dilipkumar2k6 , I was able to reach the kubemq when running locally or on docker (minikube) with the same example you sent. Please verify you are reaching the correct endpoint for minikube. If you can send more data it will be helpful Maybe try kubectl proxy.

dilipkumar2k6 commented 4 years ago

@eitam-ring thx for your followup. The following are more details.

  1. I installed kubemq using helm chart as below
    helm repo add kubemq-charts  https://kubemq-io.github.io/charts
    helm install kubemq-cluster --set token={your kubemq token} kubemq-charts/kubemq 
  2. I can kubemq pods running.
    kubectl get pods
    NAME               READY   STATUS    RESTARTS   AGE
    kubemq-cluster-0   1/1     Running   0          2m4s
    kubemq-cluster-1   1/1     Running   0          89s
    kubemq-cluster-2   1/1     Running   0          83s

    I do see the following services running

    kubectl get svc 
    NAME                      TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)                       AGE
    kubemq-cluster            ClusterIP   10.96.196.224   <none>        5228/TCP                      2m38s
    kubemq-cluster-external   ClusterIP   10.96.3.152     <none>        8080/TCP,50000/TCP,9090/TCP   2m38s
    kubernetes                ClusterIP   10.96.0.1       <none>        443/TCP                       4d16h

    Following is my minikube ip address.

    minikube ip
    192.168.99.106

    I even tried to use kubectl proxy as below; but got different error.

    kubectl proxy --port=50000
    Starting to serve on 127.0.0.1:50000

    I got following different error.

    (node:2707) UnhandledPromiseRejectionWarning: Error: Error: 14 UNAVAILABLE: Trying to connect an http1.x server
    at /Users/kubemq-nodejs/node_modules/kubemq-nodejs/queue/message_queue.js:82:32
    at Object.onReceiveStatus (/Users/kubemq-nodejs/node_modules/grpc/src/client_interceptors.js:1210:9)
    at InterceptingListener._callNext (/Users/kubemq-nodejs/node_modules/grpc/src/client_interceptors.js:568:42)
    at InterceptingListener.onReceiveStatus (/Users/kubemq-nodejs/node_modules/grpc/src/client_interceptors.js:618:8)
    at callback (/Users/kubemq-nodejs/node_modules/grpc/src/client_interceptors.js:847:24)

I am still not sure what should be my kubemq address?

eitam-ring commented 4 years ago

Your address should be localhost:50000 After you Expose kubemq-cluster-external

dilipkumar2k6 commented 4 years ago

I had to do either of the following two access from localhost.

kubemqctl cluster proxy

or

kubectl port-forward svc/kubemq-cluster-external 50000:50000

Its working fine now.