Closed brunoshine closed 7 months ago
Hi there @brunoshine, the problem is that you are setting the client's communication protocol, not the server's. There are two different communications here.
import { DaprServer, CommunicationProtocolEnum } from '@dapr/dapr';
const server = new DaprServer({
// This is important
communicationProtocol: CommunicationProtocolEnum.GRPC,
// This is optional, since by-default client will use whatever protocol server is configured with.
// Only useful if you want the client to use a different protocol than server
clientOptions: {
communicationProtocol: CommunicationProtocolEnum.GRPC
}
});
Docs https://docs.dapr.io/developing-applications/sdks/js/js-server/
Hope the above is clear, please let me know if you are still running into any issues, closing for now!
Hi @shubham1172 Thank you so much for the quick response. It worked :) Somehow I missed the server configuration part. Cheers.
By the way, sometimes I get this error:
ERRO[0005] error getting topic list from app: rpc error: code = Unavailable desc = connection error: desc = "transport: Error while dialing: dial tcp 127.0.0.1:3500: connect: connection refused" app_id=ms-azure-face-api instance=LIS-KN0084194 scope=dapr.runtime.processor.pubsub type=log ver=1.12.2
WARN[0005] failed to subscribe to topics: error occurred while beginning pubsub pubsub: rpc error: code = Unavailable desc = connection error: desc = "transport: Error while dialing: dial tcp 127.0.0.1:3500: connect: connection refused" app_id=ms-azure-face-api instance=LIS-KN0084194 scope=dapr.runtime type=log ver=1.12.2
Also the pubsub seems inconsistent. Sometimes the server gets the subscribed messages, other it dosen't. :/
Any thoughts? Thanks
@brunoshine can you share the command used to run Dapr and app? And logs from app + dapr sidecar?
The commands are:
"scripts": {
"client": "dapr run --app-id checkout --dapr-http-port 3502 --app-protocol grpc --resources-path .dapr/components/ -- node client.js",
"server": "dapr run --app-id order-processing --app-port 5002 --dapr-http-port 3501 --app-protocol grpc --resources-path .dapr/components/ -- node server.js"
},
The error error getting topic list from app: rpc error: code = Unavailable desc = connection error: desc = "transport: Error while dialing: dial tcp 127.0.0.1:3500: connect: connection refused"
I only get it from time to time.
Could you share all the logs? Or better, you can ping me on Dapr Discord under #pubsub, https://aka.ms/dapr-discord
From a chat with @brunoshine offline, this issue is no longer reproducible by them.
Expected Behavior
In this simple example I'm using the
DaprServer
to get a configuration key and also subscribe to a pubsub topic. Because Configuration requires GRPC, theClientOptions
sets the communication to grpcTo run this I'm using:
The pubsub component definition is:
Actual Behavior
When running I get an immediate error:
Steps to Reproduce the Problem
Simply add the package
@dapr/dapr
version ^3.2.0 and run the above code