Code Monkey home page Code Monkey logo

Comments (4)

thangchung avatar thangchung commented on July 22, 2024

@mihaimyh If you don't pass it down then it will use Insecure mode. See the code at https://github.com/thangchung/GrpcJsonTranscoder/blob/master/src/GrpcJsonTranscoder/DownStreamContextExtensions.cs#L62

We work on the new version at https://github.com/vietnam-devs/coolstore-microservices/tree/develop/src/building-blocks/GrpcJsonTranscoder, with more complex scenario can be found at https://github.com/vietnam-devs/coolstore-microservices/blob/develop/src/gateways/webapi-gateway/Program.cs. I will merge the latest version back to this repo soon. Will let you know after this process finish

from grpcjsontranscoder.

kollerdroid avatar kollerdroid commented on July 22, 2024

The same error for me. (System.IO.IOException: The response ended prematurely.)
When will be available the new working version?

from grpcjsontranscoder.

thangchung avatar thangchung commented on July 22, 2024

Try it again. I just deliver the update version on .NET Core 3.1. Feel free to re-open if it's still not working. Thank you

from grpcjsontranscoder.

kollerdroid avatar kollerdroid commented on July 22, 2024

The same error.
I checked the following:

var configuration = new OcelotPipelineConfiguration
{
    PreQueryStringBuilderMiddleware = async (context, next) =>
    {
        using var channel = GrpcChannel.ForAddress("http://localhost:7001");
        var client = new User.UserClient(channel);
        var result = await client.GetUserByEmailAsync(new GetUserRequest { Email = "[email protected]" });

        var jsonSerializer = new JsonSerializerSettings
        {
            ContractResolver = new CamelCasePropertyNamesContractResolver()
        };
        var response = new OkResponse<GrpcHttpContent>(new GrpcHttpContent(JsonConvert.SerializeObject(result, jsonSerializer)));

        var httpResponseMessage = new HttpResponseMessage(HttpStatusCode.OK)
        {
            Content = response.Data
        };

        context.HttpContext.Response.ContentType = "application/json";
        context.DownstreamResponse = new DownstreamResponse(httpResponseMessage);

        await next.Invoke(); //Causes System.IO.IOException: The response ended prematurely.
    }
};

It works when I remove the last line. I do not really know what happens in the pipeline after this...

from grpcjsontranscoder.

Related Issues (8)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.