NestJS Microservice Exception - rabbitmq

I'm using nestjs and I'm new in microservices,
i using RabbitMQ for microservices
App (A) is my gateway
App (B) is a service like auth
At (B) for some exception
I use throw new HTTPEXCEPTION('something', 403)
But at the gateway, i see Internal Service Error 500

Related

Securing internal REST API communication

The services(let’s call them Service A, Service B) behind the gateway are all deployed on the same machine/server. In other words, all these apps are deployed on the same tomcat instance.
What kind of security needs to be added to secure calls from gateway to service A ? I understand we can implement spring security for service A and service B as well but wanted to avoid that since gateway is already doing so and evaluate if there is a simpler approach to this.
Can internal api calls be secured with any firewall rule?
Service A and service B only host rest endpoints.

How can I implement an Amqp Server on dotnetcore for RabbitMq while tying into the Authentication Middleware?

Below is a simplified flow of the http request pipeline for asp.net-core:
A request comes into the server, a context gets created for the request, and the authentication middleware is able to authenticate a user and place the object on the HttpContext for use in the business logic.
How can I implement an Amqp Server on dotnetcore that could serve and respond to requests from (for example) a RabbitMq server? Outside of the message protocol, I would like to keep most of the features/middleware available on the http pipeline (such as the authentication middleware).

Service Fabric Health Checking

Is there an inbuilt health check for service fabric? I have a guest executable written in NET Core 2.2 and utilising the health check feature within it. For example, I have a simple health check that returns unhealthy state:
services
.AddHealthChecks()
.AddCheck<DocumentDbHealthCheck>("cosmos-database");
internal class DocumentDbHealthCheck : IHealthCheck
{
public Task<HealthCheckResult> CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken = default(CancellationToken))
{
return Task.FromResult(HealthCheckResult.Unhealthy());
}
}
I have hooked this up using:
app.UseHealthChecks(#"/foo/bar/v1/healthcheck");
However, when I locally startup my service fabric instance the state is healthy, I was expecting this to be in an errored / unhealthy state.
Is it possible to have service fabric hit the API healthcheck route?
The Healthcheck introduced on AspNetCore is a mechanism to return data about the status of some service, it does not affect the actual state of the service.
In Service Fabric, If you want to report the health from within the service to the Service Fabric health system, you can use the ReportReplicaHealth() API. something like this:
HealthInformation healthInformation = new HealthInformation("ServiceCode", "StateDictionary", HealthState.Error);
this.Partition.ReportReplicaHealth(healthInformation);
This will show in the SF Explorer as an Error.
You can also report issues using the FabricClient as described here, in this case, you would create a service to monitor other services and then report their status, aka Watchdog.
AFAIK, Service Fabric does not have an HTTP Probe mechanism to check for the health of a service, it uses the internal metrics reported by the service direct to the health sub system.
If you are planning to use it to validate if a service is healthy before sending request to it, you could user the load balancer http probes or you could just put it behind a Proxy that handles failures and forward the request to a valid node, like the Built-in Reverse Proxy as described here.

WCF Routing Service with netTcpBinding

I am using the Wcf Routing Service with the netTcpBinding
I have a WCF Service named ServiceTwo exposing just only one netTcpBinding endpoint
I have a client application consuming the ServiceTwo
Then I have a routingService between them, the routing service has two endpoints, a basicHttpBinding and a netTcpBinding. The routing always use netTcpBinding to communicate with the ServerTwo.
I am using the full IIS 8.5, enabled Http Activation and Non Http Activation, already setup protocol "http, net.tcp" for the ServiceTwo and the routing service as well.
for these below scenarios, it works
if the client application client consumes the ServiceTwo directly, not go through the routing, using netTcpBinding -> it works fine
or the client application call the ServiceTwo through the routing using basicHttpBinding (the routing always use netTcpBinding to communicate with the ServerTwo) -> it also works fine.
But for the case client app using the netTcpBinding to connect to the routing (the routing always use netTcpBinding to communicate with the ServerTwo)
I just got an exception as below:
An unhandled exception of type
System.ServiceModel.CommunicationException' occurred in mscorlib.dll
Additional information: The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '00:00:59.9659874'.
Could you please advise something I might miss and cause the error
Thank you very much.
Regards
This error occured for me, when my client was using SecurityMode.None, but not my Service. But I think the exception is rather general.
So I would advice you to re-check all values that set up your ServiceChannel incl. your Binding on Service & Client.
btw: this error occurs for me only in case the client sets a SecurityMode and the service does not! If it is vice-versa a more meaningful exception occurs. Namely: (ProtocolException - This could be due to mismatched bindings (for example security enabled on the client and not on the server))

HTTP Errors while consuming non-WCF Web Service using a WCF Client

I am trying to consume a third party web service, which is developed not in .NET but in some other langauge (may be in Java). I am trying to consume the service from WCF Client. But while adding Service reference it is throwing a error:
The HTTP request is unauthorized with client authentication scheme 'Anonymous'. The authentication header received from the server was 'basic realm="EXTRACT-CREDENTIAL"'.
Also when I am hitting the service URL in a browser it's throwing an error as follows:
HTTP GET Requests are not supported by the broker. Please use HTTP POST instead
What could be the way to consume the service from WCF client?