Skip to content

WebClient.block throws java.lang.IllegalStateException: block()/blockFirst()/blockLast() are blocking, which is not supported in thread #22919

@fedotxxl

Description

@fedotxxl

Hello
I try to use WebClient (netty) in synchronous style:

return internalWebClient
                .post()
                .uri(composeUri(ACCOUNTS_LIST_URL))
                .syncBody(userCodes)
                .retrieve()
                .bodyToFlux(UserResponse.class)
                .collectList()
                .block();

Documentation - https://github.com/spring-projects/spring-framework/blob/master/src/docs/asciidoc/web/webflux-webclient.adoc - says that it's ok but I got IllegalStateException

java.lang.IllegalStateException: block()/blockFirst()/blockLast() are blocking, which is not supported in thread reactor-http-nio-4
	at reactor.core.publisher.BlockingSingleSubscriber.blockingGet(BlockingSingleSubscriber.java:77)
	at reactor.core.publisher.Mono.block(Mono.java:1494)

Can you explain how to use WebClient in synchronous style / what's wrong / is documentation correct?

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: invalidAn issue that we don't feel is valid

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions