question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Invalid handshake response getStatus: 404 Not Found for a websocket connection

See original GitHub issue

Cloud Version : Greenwich.RELEASE Spring Boot Version: 2.1.6.RELEASE

I am trying to connect to a simple websocket and to route the connection through the gateway. Configuration is the following

  routes:
      - id: websocket
        uri: ws://localhost:10000
        predicates:
        - Path=/ws/**

I then use a simple java client to try connecting through the gateway with the socket and I get the following error:

io.netty.handler.codec.http.websocketx.WebSocketHandshakeException: Invalid handshake response getStatus: 404 
	at io.netty.handler.codec.http.websocketx.WebSocketClientHandshaker13.verify(WebSocketClientHandshaker13.java:226) ~[netty-codec-http-4.1.36.Final.jar:4.1.36.Final]
	at io.netty.handler.codec.http.websocketx.WebSocketClientHandshaker.finishHandshake(WebSocketClientHandshaker.java:276) ~[netty-codec-http-4.1.36.Final.jar:4.1.36.Final]
	at reactor.netty.http.client.WebsocketClientOperations.onInboundNext(WebsocketClientOperations.java:113) ~[reactor-netty-0.8.9.RELEASE.jar:0.8.9.RELEASE]
	at reactor.netty.channel.ChannelOperationsHandler.channelRead(ChannelOperationsHandler.java:91) ~[reactor-netty-0.8.9.RELEASE.jar:0.8.9.RELEASE]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374) ~[netty-transport-4.1.36.Final.jar:4.1.36.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:360) ~[netty-transport-4.1.36.Final.jar:4.1.36.Final]
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:352) ~[netty-transport-4.1.36.Final.jar:4.1.36.Final]
	at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:102) ~[netty-codec-4.1.36.Final.jar:4.1.36.Final]

I have not idea what I am doing wrong.

demo-micro.zip

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
TYsewyncommented, Jul 24, 2019

Hi @hectorlicea! I found the problem with your setup. The gateway was trying to connect to ws://localhost:10000/ws/test-websocket/websocket instead of ws://localhost:10000/test-websocket/websocket. Adding the StripPrefix=1 filter in your application.yml file fixed the issue.

Your route would look like this:

routes:
  - id: websocket
    uri: ws://localhost:10000
    filters:
      - StripPrefix=1
    predicates:
      - Path=/ws/**

Hope that helped! 😃

0reactions
tinaroootcommented, Dec 17, 2020

我遇到了,没有解决 我也配置了 I encountered it and did not solve it. I also configured it

`r.netty.http.client.HttpClientConnect : [id: 0x27daedae, L:/192.168.3.26:52784 - R:192.168.3.26/192.168.3.26:9444] The connection observed an error

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Gatling: WebSocketHandshakeException: Invalid handshake ...
How is this a bug? An empty path is an invalid URL, i.e. the bug is in the client not the server. ·...
Read more >
Websocket: Invalid Handshake - Google Groups
I'm currently having issues getting my websocket to connect successfully. It seems to be due to the websocket handshake key received doesn't match...
Read more >
Connection Server can not connect thingworx cluster
NettyChannelHandler - [ClientHandler: 9b8c888a] WebSocket error: Invalid handshake response getStatus: 403 Forbidden, closing connection!
Read more >
Invalid handshake response getStatus: 404 · Issue #I4ZTPP
WebSocketClientHandshakeException: Invalid handshake response getStatus: 404. 网关配置: - id: test-netty uri: lb://test-netty predicates:
Read more >
Error during WebSocket handshake: Unexpected response code
failed: Error during WebSocket handshake: Unexpected response code: 404 ... So I see now that you have put the Connection initialisation on the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found