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
Percy
Percy2y ago
Project ID: 3e72de25-24dd-4546-bc3f-c79bea6c71e3
Percy
Percy2y ago
⚠️ experimental feature
jlumos
jlumosOP2y ago
3e72de25-24dd-4546-bc3f-c79bea6c71e3
jlumos
jlumosOP2y ago
jlumos
jlumosOP2y ago
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 :/
Brody
Brody2y ago
correct me if im wrong, but are you trying to do internal networking?
jlumos
jlumosOP2y ago
mmmm no for example when the microservice starts up, it makes a request to eureka
jlumos
jlumosOP2y ago
jlumos
jlumosOP2y ago
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
Brody
Brody2y ago
then whats this ip being used for? 172.17.0.232:80
jlumos
jlumosOP2y ago
The microservice registers with its ip
Brody
Brody2y ago
thats an internal ip though
jlumos
jlumosOP2y ago
then that connection will fail always?
Brody
Brody2y ago
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 fail
jlumos
jlumosOP2y ago
OK I've changed the config to use the domain provided + that port now is working Thanks a lot ! 🙂
Brody
Brody2y ago
no problem!!
jlumos
jlumosOP2y ago
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?
jlumos
jlumosOP2y ago
jlumos
jlumosOP2y ago
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?
Brody
Brody2y ago
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
Want results from more Discord servers?
Add your server