0

I'm trying to catch TCP/IP connection resets and read timeouts when using WebClient. WebClient seems to convert these to an HTTP status. Is there a way of working out when these have occurred?

Thomas Bratt
  • 48,038
  • 36
  • 121
  • 139
  • “WebClient seems to convert these to an HTTP status” - typically which http status do you receive in a response when the connection is interrupted? – John Williams Apr 25 '23 at 16:22
  • I'm getting 404. – Thomas Bratt Apr 25 '23 at 16:56
  • A 404 is definitely not a connection issue. The request has made its way to the server. The server does not have code to service the path called so responds with a 404 (not_found). – John Williams Apr 25 '23 at 17:12
  • Agreed but I've made sure the server isn't listening and I still get 404. I'm wondering if it's a limitation of WebClient? – Thomas Bratt Apr 25 '23 at 19:28
  • A 404 is a response from something that talks http. Do you have any sort of proxy between client and server that might return a 404 to a client when the proxy can’t reach the server. – John Williams Apr 25 '23 at 19:32
  • I guess the question is - how to tell when a connection *does* fail? – Thomas Bratt Apr 26 '23 at 05:57
  • I think that the answers here are a good start - https://stackoverflow.com/questions/65841285/handling-connection-errors-in-spring-reactive-webclient . Just to reiterate, http errors (4xx & 5xx) are not generated by WebClient. They are returned by servers (or possibly by proxies, eg nginx) – John Williams Apr 26 '23 at 08:56

0 Answers0