R
Railway16mo ago
jlumos

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