Juliette
Juliette

Reputation: 1036

Spring Websocket not working with ssl (wss)

I have an application with a websocket connection between a Spring backend and an Angular Frontend behind a Spring Cloud Gateway which works perfectly via http / ws but doesn't work at all.

What I tried and what worked:

What does not work:

I configured the spring cloud gateway as described here https://cloud.spring.io/spring-cloud-gateway/reference/html/:

    - id: websocketinfo
      uri: http://app
      predicates:
        - Host=app.domain.com
        - Path=/api/ws/info/**
    - id: websocket
      uri: ws://app
      predicates:
        - Host=app.domain.com
        - Path=/api/ws/**

The only difference between my local gateway (with which the websocket communication works) and the server gateway is that I have ssl enabled on the server with a p12 key

The error message that I get in the spring cloud gateway is:

io.netty.handler.codec.http.websocketx.WebSocketHandshakeException: Invalid handshake response getStatus: 403

In the Spring Backend Service I get these errors a lot:

2020-04-09 07:03:55.298  WARN 1 --- [p-nio-80-exec-4] .w.s.m.s.DefaultHandlerExceptionResolver : Resolved [org.springframework.http.converter.HttpMessageNotWritableException: No converter for [class java.util.LinkedHashMap] with preset Content-Type 'application/javascript;charset=UTF-8']

This confuses me a lot since that seems like the kind of error that should happen no matter which environment you run the application in

Upvotes: 1

Views: 1869

Answers (1)

Juliette
Juliette

Reputation: 1036

So apparently this was a bug with an older version of spring cloud gateway. After updating to spring version 2.2.1 everything worked with ssl too

Upvotes: 1

Related Questions