Giter Club home page Giter Club logo

s04e03---.net-microservices-course-'s People

Contributors

binarythistle avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

s04e03---.net-microservices-course-'s Issues

POST request to CommandsService from PlatformService using HttpClient class failed with 404 status code

PlatformService container's logs:

{"EventId":100,"LogLevel":"Information","Category":"System.Net.Http.HttpClient.ICommandDataClient.LogicalHandler","Message":"Start processing HTTP request POST http://commands-clusterip-srv/api/commands/platforms/","State":{"Message":"Start processing HTTP request POST http://commands-clusterip-srv/api/commands/platforms/","HttpMethod":"POST","Uri":"http://commands-clusterip-srv/api/commands/platforms/","{OriginalFormat}":"Start processing HTTP request {HttpMethod} {Uri}"}}

{"EventId":100,"LogLevel":"Information","Category":"System.Net.Http.HttpClient.ICommandDataClient.ClientHandler","Message":"Sending HTTP request POST http://commands-clusterip-srv/api/commands/platforms/","State":{"Message":"Sending HTTP request POST http://commands-clusterip-srv/api/commands/platforms/","HttpMethod":"POST","Uri":"http://commands-clusterip-srv/api/commands/platforms/","{OriginalFormat}":"Sending HTTP request {HttpMethod} {Uri}"}}

{"EventId":101,"LogLevel":"Information","Category":"System.Net.Http.HttpClient.ICommandDataClient.ClientHandler","Message":"Received HTTP response headers after 90.6421ms - 404","State":{"Message":"Received HTTP response headers after 90.6421ms - 404","ElapsedMilliseconds":90.6421,"StatusCode":404,"{OriginalFormat}":"Received HTTP response headers after {ElapsedMilliseconds}ms - {StatusCode}"}}

{"EventId":101,"LogLevel":"Information","Category":"System.Net.Http.HttpClient.ICommandDataClient.LogicalHandler","Message":"End processing HTTP request after 103.0619ms - 404","State":{"Message":"End processing HTTP request after 103.0619ms - 404","ElapsedMilliseconds":103.0619,"StatusCode":404,"{OriginalFormat}":"End processing HTTP request after {ElapsedMilliseconds}ms - {StatusCode}"}}


Exception Caught!
Sync POST to CommandsService failed!
Message :Response status code does not indicate success: 404 (Not Found). 

SendPlatformToCommand:

public async Task SendPlatformToCommand(PlatformReadDto platform)
        {
            try
            {
                var httpContent = new StringContent(
                JsonSerializer.Serialize(platform),
                Encoding.UTF8,
                "application/json"
                );

                // var response = await _httpClient.PostAsync($"{_configuration["CommandService"]}", httpContent);

                // if (response.IsSuccessStatusCode)
                // {
                //     Console.WriteLine("Sync POST to CommandsService success!");
                // }
                // else
                // {
                //     Console.WriteLine("Sync POST to CommandsService failed!");
                // }

                HttpResponseMessage response = await _httpClient.PostAsync($"{_configuration["CommandService"]}", httpContent);

                response.EnsureSuccessStatusCode();
                Console.WriteLine("Sync POST to CommandsService success!");

            }
            catch (HttpRequestException ex)
            {
                Console.WriteLine("\nException Caught!");
                Console.WriteLine("Sync POST to CommandsService failed!");
                Console.WriteLine("Message :{0} ", ex.Message);
            }

Can anyone tell me what the problem is? Thank you.

[FYI] Issue when using MSSQL on the CommandsService Project

For those like me that went the MSSQL route on the CommandsService Project instead of keeping it in memory, you will most likely run into an issue with inserting a platform in the EventProcessor that does not happen when using in memory.

The mapping used for PlatformPublishedDto

CreateMap<PlatformPublishedDto, Platform>()
                .ForMember(dest => dest.ExternalId, opt => opt.MapFrom(src => src.Id));

while mapping the PlatformService's PlatformPublishedDto.Id to a CommandsService's PlatformPublishedDto.ExternalId , it will leave the same PlatformService's PlatformPublishedDto.Id also mapped to the CommandsService's PlatformPublishedDto.Id

That will cause MSSQL to complain about inserting with an explicit IDENTITY.

To fix this, you have to tell AutoMapper to ignore Id on the destination like below:

CreateMap<PlatformPublishedDto, Platform>()
                .ForMember(dest => dest.ExternalId, opt => opt.MapFrom(src => src.Id))
                .ForMember(dest => dest.Id, opt => opt.Ignore());

Can't connect to mssql server localhost, 1433

Can't connect as user sa, its just sending me Login failed for user 'sa' error:18456,
changed line 25 env name in mssql-plat-depl.yaml file from SA_PASSWORD to MSSQL_SA_PASSWORD, but that didn't help either

Then tried to reapply this deployament and restart it by 2 commands:
1) kubectl apply -f mssql-plat-depl.yaml
2) kubectl rollout restart deployment mssql-depl

Who faced similar problem? Any ideas?

Could not able to connect with ClusterIp from Ingress (404 error)

Hi,

I'm getting 404 error while trying to connect (acme.com/api/platform) platform service from Ingress, but can able to connect with NodePort (localhost:3xxxx/api/platform).
after researching in Internet and apply many troubleshooting I feel like Ingress cannot able to connect with the Platform-ClusterIp-srv (correct me if im wrong)

ingress-srv.yaml

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: ingress-srv
annotations:
kubernetes.io/ingress.class: "nginx"
nginx.ingress.kubernetes.io/use-regex: 'true'
spec:
rules:
- host: acme.com
http:
paths:
- path: /api/platform
pathType: Prefix
backend:
service:
name: platforms-clusterip-srv
port:
number: 80
- path: /api/c/Platform
pathType: Prefix
backend:
service:
name: commands-clusterip-srv
port:
number: 80`

platform.depl.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
name: platforms-depl
spec:
replicas: 1
selector:
matchLabels:
app: platformservice
template:
metadata:
labels:
app: platformservice
spec:
containers:
- name: platformservice
image: virtualking/platformservice

apiVersion: v1
kind: Service
metadata:
name: platforms-clusterip-srv
spec:
type: ClusterIP
selector:
app: platformservice
ports:
- name: platformservice
protocol: TCP
port: 80
targetPort: 80

Note: In tutorial, he used v0.48.1 Ingress.
I used this v1.0.4. https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.0.4/deploy/static/provider/cloud/deploy.yaml

kubectl get pods command error

After this command , we should get 1/1 but I am not getting , then I check using kubectl describe pod <pod_name> and I got following error: Failed to pull image "aero016/plateformservice:latest": rpc error: code = Unknown desc = Error response from daemon: pull access denied for aero016/plateformservice, repository does not exist or may require 'docker login': denied: requested access to the resource is denied

After getting this error I have logged in using docker login and still I am getting error then I have checked that my image is present or not , my image also present and also my image is public . So now can anyone help me about this issue??? And also I have tried to pull image locally using docker pull and It is working fine but I am getting this error>>>

I can't access the host name without port number

In the tutorial, I set the hostname to "acme.com" in ingress-srv.yaml and applied it. However, when I tried to access it, it was inaccessible even after I changed the default IIS port. Upon listing services in the ingress namespace, I attempted to access the host using "acme.com:31348/api/platforms" and it worked. Is this behavior normal? How can I access it using the default port (80)?
image
image

PlatformService(Create_Method) httpClient call to commandService

  Sending HTTP request POST http://localhost:6000/api/c/platforms/

--> Could not send synchronously : The SSL connection could not be established, see inner exception.
--> inner exception. : The remote certificate is invalid because of errors in the certificate chain: UntrustedRoot

[Suggestion] Use a command line argument to handle migration

Hey! Great Course BTW.

There is one thing I found so cumbersome that I had to go out of my way to fix it on my project, the commenting/uncommenting for migration to use SqlServer.

Here's how I handled it (note, my project is a "no startup" project, so some minor adaptation would be required in Startup).

In Program.cs

var dbProvider = builder.Configuration.GetValue("Provider", "InMemory");
if(builder.Environment.IsProduction() || dbProvider == "SqlServer") {
    // AddDbContext using SqlServer Database
} else {
    // AddDbContext using InMemory Database
}

When generating migrations
dotnet ef Migrations add {MigrationName} -- --provider SqlServer where {MigrationName} is the name of the migration you want to add.

Such a simple fix to avoid commenting/uncommenting every times you want to add a migration I thought I would share.

Building with newwer versions of .NET (micro - tutorial)

I came across some problems while trying to create this project myself here is a solution

FROM mcr.microsoft.com/dotnet/aspnet:7.0
WORKDIR /app
COPY --from=build-env /app/out .
RUN sed -i 's/CipherString = DEFAULT@SECLEVEL=2/CipherString = DEFAULT@SECLEVEL=1/g' /etc/ssl/openssl.cnf
ENTRYPOINT ["dotnet", "UserService.dll"]

It is the first change more about it in dotnet/SqlClient#633
Second one is adding TrustServerCertificate=true; to your connection string aka "PlatformsConn" in this project

For now those are all the errors i have spotted i will post more if i find any.

Grpc Not connecting from CommandService

Building...
--> Calling GRPC Service https://localhost:5001
--> Couldnot call GRPC Server Status(StatusCode="Internal", Detail="Error starting gRPC call. HttpRequestException: Requesting HTTP version 2.0 with version policy RequestVersionOrHigher while unable to establish HTTP/2 connection.", DebugException="System.Net.Http.HttpRequestException: Requesting HTTP version 2.0 with version policy RequestVersionOrHigher while unable to establish HTTP/2 connection.
at System.Net.Http.HttpConnectionPool.ThrowGetVersionException(HttpRequestMessage request, Int32 desiredVersion)
at System.Net.Http.HttpConnectionPool.SendWithVersionDetectionAndRetryAsync(HttpRequestMessage request, Boolean async, Boolean doRequestAuth, CancellationToken cancellationToken)
at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, Boolean async, 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)")
Seeding new platforms...
Unhandled exception. System.NullReferenceException: Object reference not set to an instance of an object.
at CommandsService.Data.PrepDb.SeedData(ICommandRepo repo, IEnumerable`1 platforms) in /Users/Project/PS/CommandsService/Data/PrepDb.cs:line 28
at CommandsService.Data.PrepDb.PrepPopulation(IApplicationBuilder applicationBuilder) in /Users/Project/PS/CommandsService/Data/PrepDb.cs:line 20
at Program.

$(String[] args) in /Users/Project/PS/CommandsService/Program.cs:line 55

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.