Expand Authors Top

If you have a few years of experience in the Java ecosystem and you’d like to share that with the community, have a look at our Contribution Guidelines.

Expanded Audience – Frontegg – Security (partner)
announcement - icon User management is very complex, when implemented properly. No surprise here.

Not having to roll all of that out manually, but instead integrating a mature, fully-fledged solution - yeah, that makes a lot of sense.
That's basically what Frontegg is - User Management for your application. It's focused on making your app scalable, secure and enjoyable for your users.
From signup to authentication, it supports simple scenarios all the way to complex and custom application logic.

Have a look:

>> Elegant User Management, Tailor-made for B2B SaaS

Generic Top

Get started with Spring 5 and Spring Boot 2, through the Learn Spring course:


1. Introduction

Spring Cloud Feign Client is a handy declarative REST client, that we use to implement communication between microservices.

In this short tutorial, we'll show how to set a custom Feign Client connection timeout, both globally and per client.

2. Defaults

Feign Client is pretty configurable.

In terms of a timeout, it allows us to configure both read and connection timeouts. Connection timeout is the time needed for the TCP handshake, while the read timeout needed to read data from the socket.

Connection and read timeouts are by default 10 and 60 seconds, respectively.

3. Globally

We can set the connection and read timeouts that apply to every Feign Client in the application via the feign.client.config.default property set in our application.yml file:

        connectTimeout: 60000
        readTimeout: 10000

The values represent the number of milliseconds before a timeout occurs.

4. Per-client

It's also possible to set these timeouts per specific client by naming the client:

        connectTimeout: 10000
        readTimeout: 20000

And, we could, of course, list a global setting and also per-client overrides together without a problem.

5. Conclusion

In this tutorial, we explained how to tweak Feign Client's timeouts and how to set custom values through the application.yml file. Feel free to try these out by following our main Feign introduction.

Generic bottom

Get started with Spring 5 and Spring Boot 2, through the Learn Spring course:

Cloud footer banner
Comments are closed on this article!