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

question about "-dapr-grpc-port" #995

Closed
q7314568 opened this issue Dec 13, 2022 · 3 comments
Closed

question about "-dapr-grpc-port" #995

q7314568 opened this issue Dec 13, 2022 · 3 comments
Labels
question Further information is requested

Comments

@q7314568
Copy link

q7314568 commented Dec 13, 2022

I started a demo with dap sdk,and trying to use docker-compose to debug locally.

everyting working fine with http,

but once i set "-dapr-grpc-port",all http action with daprClient starting to get error

Dapr.DaprException: State operation failed: the Dapr endpoint indicated a failure. See InnerException for details.
---> Grpc.Core.RpcException: Status(StatusCode="Unavailable", Detail="Error connecting to subchannel.", DebugException="System.Net.Sockets.SocketException (111): Connection refused
at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ThrowException(SocketError error, CancellationToken cancellationToken)
at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.System.Threading.Tasks.Sources.IValueTaskSource.GetResult(Int16 token)
at System.Net.Sockets.Socket.g__WaitForConnectWithCancellation|281_0(AwaitableSocketAsyncEventArgs saea, ValueTask connectTask, CancellationToken cancellationToken)
at Grpc.Net.Client.Balancer.Internal.SocketConnectivitySubchannelTransport.TryConnectAsync(CancellationToken cancellationToken)")
at Grpc.Net.Client.Balancer.Internal.ConnectionManager.PickAsync(PickContext context, Boolean waitForReady, CancellationToken cancellationToken)
at Grpc.Net.Client.Balancer.Internal.BalancerHttpHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at Grpc.Net.Client.Internal.GrpcCall2.RunCall(HttpRequestMessage request, Nullable1 timeout)
at Dapr.Client.DaprClientGrpc.GetStateAsync[TValue](String storeName, String key, Nullable1 consistencyMode, IReadOnlyDictionary2 metadata, CancellationToken cancellationToken)
--- End of inner exception stack trace ---
at Dapr.Client.DaprClientGrpc.GetStateAsync[TValue](String storeName, String key, Nullable1 consistencyMode, IReadOnlyDictionary2 metadata, CancellationToken cancellationToken)
at DaprCounterASPNET.Controllers.WeatherForecastController.GetCounter(DaprClient daprClient) in D:\work\1.WorkSpace\1.dotNET\DaprCounterASPNET\Controllers\WeatherForecastController.cs:line 37
at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.TaskOfIActionResultExecutor.Execute(ActionContext actionContext, IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|20_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
at Microsoft.AspNetCore.Routing.EndpointMiddleware.g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
at Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware.Invoke(HttpContext httpContext)
at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider)
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddlewareImpl.Invoke(HttpContext context)

compose cmd:

command: ["./daprd",
    "-app-id", "daprcounteraspnet",
    "-app-port", "80",
    "-placement-host-address", "placement:50006",
    "-dapr-grpc-port", "3501",
    "-app-protocol", "grpc",
    "-app-protocol", "http",
    "-components-path", "/components"]

please help me figure out how to set both http & grpc up,and can both work in same service,thx

Here is my demo repo:
https://github.com/q7314568/DaprCounterASPNET

@halspang
Copy link
Contributor

halspang commented Jan 6, 2023

@q7314568 - You can't have your app be both gRPC and http. You'll have to choose one or the other.

As for --dapr-grpc-port, that is the port that Dapr itself stands up on and that you will use to communicate with it. The issue here is that when you run dapr and your app together, the ports are given to the app via environment variables. When you start Dapr separately and don't give your app the ports, it'll fail to connect because it expects to find Dapr on its default ports.

Does this answer your question?

@halspang halspang added the question Further information is requested label Jan 6, 2023
@q7314568 q7314568 closed this as completed Jan 7, 2023
@q7314568
Copy link
Author

q7314568 commented Jan 7, 2023

@q7314568 - You can't have your app be both gRPC and http. You'll have to choose one or the other.

As for --dapr-grpc-port, that is the port that Dapr itself stands up on and that you will use to communicate with it. The issue here is that when you run dapr and your app together, the ports are given to the app via environment variables. When you start Dapr separately and don't give your app the ports, it'll fail to connect because it expects to find Dapr on its default ports.

Does this answer your question?

I endup found out i need to set endpoint for both of gRpc and http,and the proj can hit the web api again,thanks anyway

@GebTandon
Copy link

Sorry I'm late in the game, @q7314568 , can you post example of how to got it to work?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants