Spring Eureka & Cloud Gateway and microservice resolution
I have deployed a three-service project which contains:
- Eureka Server
- Spring Cloud gateway (api gw, reverse proxy)
- 1 API Microservice
Both gateway and microservice are being registered by Eureka, so, the connectivity works in this case.
But, I am trying to access my microservice through the proxy and then my proxy receives a connection time out trying to reach the microservice.
I've seen this thread which is exactly my problem but the solution is not working.... any idea? any spring expert?
https://stackoverflow.com/questions/74534610/error-500-on-spring-cloud-gateway-finishconnect-on-heroku
Stack Overflow
Error 500 on spring cloud gateway finishConnect(..) on Heroku
I use Eureka with spring boot£. 1 server, 1 gateway, and 2 api, in my localhost i have no problems but when i deploy it on Heroku i can't reach an api through the api gateway. The EUREKA server dis...
20 Replies
Project ID:
3e72de25-24dd-4546-bc3f-c79bea6c71e3
You might find these helpful:
- Spring Boot App only accessible without port
- NGINX Gateway Throws HTTP Error426
- Backend Deployment
⚠️ experimental feature
3e72de25-24dd-4546-bc3f-c79bea6c71e3
Original Stack Trace:
Caused by: java.net.ConnectException: finishConnect(..) failed: Connection refused
........
2023-03-26T19:32:37.238Z ERROR 1 --- [or-http-epoll-7] a.w.r.e.AbstractErrorWebExceptionHandler : [0e2b1454-46] 500 Server Error for HTTP GET "/ms-pizza-catalogue/pizzas"
io.netty.channel.AbstractChannel$AnnotatedConnectException: finishConnect(..) failed: Connection refused: /172.17.0.232:80
If you try to access to the microservice directly, everything works
https://back-end-pizza-catalogue-production.up.railway.app/pizzas
also, the gw knows the route
https://back-end-cloud-gateway.up.railway.app/actuator/gateway/routes
but looks like there's no connection between them :/
correct me if im wrong, but are you trying to do internal networking?
mmmm no
for example when the microservice starts up, it makes a request to eureka
in this case, a request to https://unir-backend-eureka.up.railway.app/
https://unir-backend-eureka.up.railway.app/eureka
that's working
but, when I use the gateway to acces my ms, the gateway must ask Eureka for the IP of the ms
I've tried to configure the componentes to perform the call with IP and hostname
failing in both scenarios
then whats this ip being used for?
172.17.0.232:80
The microservice registers with its ip
thats an internal ip though
then that connection will fail always?
well yeah, theres no internal networking
if a service is trying to connect to a different service over
172.17.0.232:80
it will fail, connections between services must be done through the public railway provided domain (or your custom domain) and port 443, all else will failOK I've changed the config to use the domain provided + that port
now is working
Thanks a lot ! 🙂
no problem!!
Another question for you... @Brody
I'm trying to execute a POST request to my service like this one
curl --location 'https://back-end-cloud-gateway.up.railway.app/ms-pizza-catalogue/ingredients' \
--header 'Content-Type: application/json' \
--data '{
"name": "sausage white",
"description": "One of our delicious ingredients!",
"vegan": false
}'
but the service is treating it as a GET
Do you know why?
Solved, I was exposing services via port 80, now over 443 and it works fine and POST is being recognized
post is redirected for port 80?
no, it's just something funky with the proxy since you should be listening on the environment variable PORT that railway will auto generate and inject