Eureka not discovering service by name - spring-boot

I'm running simple eureka service discovery example as given in the link below :
https://www.logicbig.com/tutorials/spring-framework/spring-cloud/rest-template-load-balancer.html
I observed that while I am running this example on my home wifi/personal laptop this runs fine whereas while it runs on my office workstation on the corporate network, the resttemplate in unable to resolve the services by their name. (get 407 proxy unauthorized)
I can see that both the services are getting successfully registered on Eureka.
What might be stopping the Eureka server to work correctly on the corporate network?
P.S.: By following the answer and making the resttemplate and proxy aware results in 503 services unavailable.

You should configure your rest template to be proxy aware. You can find how to do this here

Related

Services communication in consul

I am developing several services, and use consul as the service registry. I'm able to register all of my services to the consul.
And now for the next thing to do, I need to be able to communicate from service A to service B.
Without a service registry, usually what I did was simply dispatch a client HTTP request from service A to service B.
But since now I already have service discovery in place, should I get the service B host address via consul and then dispatch a client HTTP request to the service B host address something like that? Or does the consul also provide an API gateway, so I only need to dispatch my client HTTP request from service A to the consul, and then the consul will automatically forward it to the destination?
Also if there is relevant documentation about my case, I would be very glad to take a look at it? (I can't find the relevant documentation, probably my google search keyword is wrong)
Consul supports two methods for service discovery, DNS and HTTP.
Applications can perform DNS lookups against their local Consul agent which exposes a DNS server on port 8600 (you can also configure DNS forwarding). For example, an application can issue an A record query for web.service.consul and Consul will return a list of healthy instance endpoints for the web service. SRV lookups are also supported in order to retrieve the IP and port for a given service. The DNS interface also supports querying endpoints by service tag and data center. Details can be found at Consul.io: DNS - Service Lookups.
HTTP-based service discovery can be performed by querying the /v1/health/service/:name endpoint against the local agent. The following will return a full list of healthy and unhealthy endpoints for the service nginx.
$ curl http://127.0.0.1:8500/v1/health/service/nginx
You can use the passing query parameter to restrict the output to only healthy services.
$ curl "http://127.0.0.1:8500/v1/health/service/nginx?passing"
I recommend reviewing the guide Register a Service with Consul Service Discovery for more info on registering and querying services from the catalog.
Lastly, API gateways like Traefik and Solo's Gloo support using Consul for service discovery (see Traefik's Consul Catalog Provider and Gloo's Consul Services). You could configure your services to route requests to these gateways, and allow the gateway to forward to the backend destination.
I ended up getting the list of services info from the consul, and then perform name matching on it then get the service address.
I use this endpoint to get the list of the services and it's data:
http://localhost:8500/v1/agent/services
So it's the client-side discovery I guess.

How to disable/configure the Spring Cloud Gateway rewriting of Location headers

We have a setup with Spring Cloud Gateway running with consul service discovery and proxying requests to services in a cluster.
When one of these services responds with a Location: / header this gets rewritten on the way out thru the gateway.
The problem is that the gateway seems to add the service local hostname and port as found in Consul. This url is of course not available (or desirable) for the client.
I have verified thet the upstream server sends:
Location: /
(Generated by the "redirect: /" Spring MCV shorthand)
But when it reached the end client is rewritten to:
Location: https://10.0.0.10:34567/
(https://10.0.0.10:34567/ being the upstream location of the service in consul)
If is of course incorrect.
My problem is that I can't find any documentation on how to configure this and no indication of what classes are used (to debug) so I just don't know where to start looking for the fix.
The desired behaviour is of course to just leave the redirect unchanged.
In this particular case we use a host based routing setup:
.route("app", r -> r.host("app.**").uri("lb://app"))
Any help or hint appreciated.

Access to a self-hosted WCF service on azure virtual machine over the Internet

Actually the question is kind of duplication of the following one Unable to access a locally hosted wcf service over the internet but with only difference that the service is hosted by a windows service on Azure Virtual Machine.
I can access the service on the machine and I have added an endpoint to the service port at Azure Configuration console, but still cannot access the service over the Internet.
The error message that is not possible to set up connection.
Is my scenario technical possible on azure? if yes - what is done wrong?
The answer to my question was pretty straightforward. Although I opened my endpoint in Azure Management Console the port was blocked by the virtual machine firewall (windows firewall). After setting in- and out- tcp port rule, the problem had gone.

Mule on Amazon Cloud

I installed Mule Community Server on AWS cloud and it is functioning properly. When I use http end point and invoke Mule services from browser on my Amazon EC2 machine they work. When I access them from outside, the request timeout. The end points are not bound to local host but mapped to 0.0.0.0:8081. I have checked all firewall settings using amaozon security group and set permission for all. Yet it doesnt work. I am able to access the Windows IIS http server on the same machine but not mule on port 8081. Any clues would help.
Hope this doesn't sound rude, but did you disable the windows firewall, or allow 8081 through the windows firewall?

WCF Service throwing error in WCF Service Host

I'm having some trouble with a WCF Service. When I host it in IIS, it runs fine, but I figure there is a problem somewhere.
When I run my WCF Service in Visual Studio 2010, it brings up the WCF Service Host.
It names the host, then the status is 'Error'.
The error it gave is this:
System.ServiceModel.AddressAlreadyInUseException: HTTP could not register URL http://+:8732/Design_Time_Addresses/EvalServiceLibrary/Service1/. Another application has already registered this URL with HTTP.SYS. ---> System.Net.HttpListenerException: Failed to listen on prefix 'http://+:8732/Design_Time_Addresses/EvalServiceLibrary/Service1/' because it conflicts with an existing registration on the machine.
I don't know if this has affected the service deployed in IIS, since that tells me I have created a service if I browse it through IIS.
Any ideas?
It's pretty clear, the address is already in use.
Does the service in IIS run on the same port? Change it, or change your port for the development.

Resources