Affects: 6.0.7

I have a server that uses the koa-websocket framework to provide both HTTP and WebSocket services on the same port. When I try to access the HTTP interface using @HttpExchange, I receive an "Invalid Upgrade header" error. Adding "Upgrade-Insecure-Requests=1" to the header produces the same error.

@HttpExchange(value = "http://127.0.0.1:3080/question", contentType = "application/json")
public interface OfficiallyAccount2 {

    @GetExchange("")
    ResponseEntity<Void> test();
}
@Configuration(proxyBeanMethods = false)
public class WebClientConfiguration {
    @Bean
    public OfficiallyAccount2 albumsClient(WebClient.Builder webClientBuilder) {
        WebClient webClient =
                webClientBuilder
                    .defaultHeader(HttpHeaders.UPGRADE_INSECURE_REQUESTS, "1")


        return HttpServiceProxyFactory.builder()
                .clientAdapter(WebClientAdapter.forClient(webClient))
                .build()
                .createClient(OfficiallyAccount2.class);
    }
}

using RestTemplate does not cause any issues.

Comment From: bclozel

This is probably linked to the server implementation. Why is the server assuming that the client is trying to upgrade to a websocket connection?

It would greatly help if you could configure the Reactor Netty client to wiretap the traffic by doing this:

ReactorClientHttpConnector connector = new ReactorClientHttpConnector(HttpClient.create().wiretap(true).compress(true));
this.webClient = webClientBuilder.clientConnector(connector).build();

And configuring the logging levels to "DEBUG" for reactor.netty.http.client (here, an application.yml file sample if you're using Spring Boot):

logging:
  level:
    reactor.netty.http.client: DEBUG

Could you share the logs showing the actual HTTP traffic that you'll get with this setup?

Comment From: shuli495

I have no problem creating WebClients this way

ReactorClientHttpConnector connector = new ReactorClientHttpConnector(HttpClient.create().wiretap(true).compress(true));
this.webClient = webClientBuilder.clientConnector(connector).build();

thanks!