spring-cloud / spring-cloud-netflix

Integration with Netflix OSS components
http://cloud.spring.io/spring-cloud-netflix/
Apache License 2.0
4.88k stars 2.44k forks source link

No such host is known (swagger-service) #4276

Closed otaku0304 closed 7 months ago

otaku0304 commented 7 months ago

Hello,

I'm encountering an issue with microservices architecture. Specifically, when I attempt to access the microservices using with the application names, I receive an error stating "No such host is known". This problem arises even though I have set up an Eureka Discovery Server along with three Eureka client servers. As I am new to microservices, this is my first project, and I would greatly appreciate any guidance or assistance you can provide. Thank you for your understanding.

SpringBoot versions and Spring cloud versions for all micro services SpringBoot version = 3.2.4 Spring Cloud version = 2023.0.0 java Version = 21 Eureka localhost dashboard running at 8761

image

Application names and port numbers were defined separately in each yml files as swag-service, swagger-service, swaggest-service. so below is the swag yml file that show the application name

image

swagger yml file

image

Port numbers for microservices 8081, 8082, 8083 below is the swag yml file and running in the port 8081

image

When I changed the hostname and port numbers to include the application name, I encountered an error. However, the application is working fine when I used localhost and port numbers.

image

swagApplication

image

SwaggerApplication

image

swag controller with swag endpoint (/swag) calling save-swagger endpoint

image

swagService

image

swaggerController with (/swagger) hitting save end point

image

swaggerService

image

When i make an request from swag endpoint to save swagger I was getting the hostName error with 500 internal error

image

error

image

image

OlgaMaciaszek commented 7 months ago

Hello @otaku0304. It seems like an issue with Eureka setup. I will transfer it to spring-cloud-netflix. I can take a look at it for you, but please provide a minimal, complete, verifiable example that reproduces the issue as a link to a GH repo with a small executable app.

otaku0304 commented 7 months ago

Hi @OlgaMaciaszek https://github.com/otaku0304/Swag-Micro-Services https://github.com/otaku0304/config-repo please clone the repos from this link and run the applications,

Once after applications are running send POST request to the below url by using the postman and pass the requestBody as a json body, you will get the error.

url: http://localhost:8081/swag/save-swaggest

{ "swaggestContent": "Elon Musk1", "user": "sai" }

error: { "responseCode": 400, "token": null, "responseMessage": "I/O error on POST request for \"http://swaggest-service/swaggest/save\": No such host is known (swaggest-service)", "responseBody": null }

OlgaMaciaszek commented 7 months ago

@otaku0304 thanks, but please provide a minimal sample, with only as many services doing only as mush as absolutely necessary to reproduce the issue (this provided sample runs a lot of stuff unrelated to Spring Cloud Netflix, including a MongoDB).

spring-cloud-issues commented 7 months ago

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

spring-cloud-issues commented 7 months ago

Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.