Hi, Yes i am using grpc-web.
Is there any other way to implement other than using Envoy? thanks. On Friday, May 29, 2020 at 2:33:45 PM UTC-5, Stanley Cheung wrote: > > On your first code snippet, what is "grpc.unary"? > > On your second approach, are you using grpc-web > <https://github.com/grpc/grpc-web/>? If so, you need to set up Envoy to > handle the CORS request (and handle the grpc-web requests in general) like > this > <https://github.com/grpc/grpc-web/blob/master/net/grpc/gateway/examples/helloworld/envoy.yaml#L27> > . > > In general grpc-web browser clients cannot directly talk to a grpc backend > server. You need Envoy and grpc-web to do the translation. See > https://github.com/grpc/grpc-web/tree/master/net/grpc/gateway/examples/helloworld > for > an example. > > On Fri, May 29, 2020 at 11:19 AM XCompiler <salva...@gmail.com > <javascript:>> wrote: > >> I am trying to call a grpc service (the service in created using c#) in >> angular. i did not used docker on this. i just run the grpc service on my >> local machine. see code below. >> >> const AbcRequest = new DomainMessage(); >> >> nexusRequest.setMesssage("QueryTest"); >> >> >> >> grpc.unary(AbcService.Fields, { >> >> request: AbcRequest, >> >> host: "https://localhost:5001/", >> >> onEnd: res =>{ >> >> const { status, statusMessage, headers, message, trailers } = res >> ; >> >> if (status === grpc.Code.OK && message) { >> >> var result = message.toObject() as AbcResponse.AsObject; >> >> >> >> this.response = result.jsonresponsedata; >> >> } >> >> } >> >> }); >> >> the message.toObject() is always null and the error below >> >> "Error: Response closed without headers >> >> at Object.onEnd (http://localhost:4200/main.js:1257:21) >> >> at http://localhost:4200/vendor.js:62504:24946 >> >> at Array.<anonymous> (http://localhost:4200/vendor.js:62504:5685) >> >> at e (http://localhost:4200/vendor.js:62504:1567) >> >> at http://localhost:4200/vendor.js:62504:1681 >> >> at ZoneDelegate.invokeTask (http://localhost:4200/polyfills.js:412:35 >> ) >> >> at Object.onInvokeTask (http://localhost:4200/vendor.js:44161:33) >> >> at ZoneDelegate.invokeTask (http://localhost:4200/polyfills.js:411:40 >> ) >> >> at Zone.runTask (http://localhost:4200/polyfills.js:180:51) >> >> at invokeTask (http://localhost:4200/polyfills.js:493:38)" >> >> >> >> i tried another approach. see code below. >> >> const service = new AbcServiceClient('https://localhost:5001', null); >> >> const request = new DomainMessage(); >> >> request.setMesssage('QueryTest'); >> >> >> >> service.fields(request, null, (err, response: AbcField) => { >> >> console.log(response.toObject()); >> >> if (err) { >> >> console.log(err); >> >> } >> >> }); >> >> >> >> and this one give me CORS error. see error below. >> >> Access to fetch at 'https://localhost:5001//AbcApi.AbcService/Fields >> <https://localhost:5001//NexusApi.NexusService/Fields>' from origin ' >> http://localhost:4200' has been blocked by CORS policy: >> >> Response to preflight request doesn't pass access control check: No >> 'Access-Control-Allow-Origin' header is present on the requested resource. >> >> If an opaque response serves your needs, set the request's mode to >> 'no-cors' to fetch the resource with CORS disabled. >> >> >> >> Is it possible to run angular accessing grpc with out using docker? >> >> >> thanks. >> >> -- >> You received this message because you are subscribed to the Google Groups >> "grpc.io" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to grp...@googlegroups.com <javascript:>. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/grpc-io/0949924e-ee23-44e3-acc2-c52dab1065e6%40googlegroups.com >> >> <https://groups.google.com/d/msgid/grpc-io/0949924e-ee23-44e3-acc2-c52dab1065e6%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> > -- You received this message because you are subscribed to the Google Groups "grpc.io" group. To unsubscribe from this group and stop receiving emails from it, send an email to grpc-io+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/98e0e58f-6369-4700-8224-1a866301bd61%40googlegroups.com.