Skip to content

Project that demonstrates the issues with trying to proxy external web socket requests using spring cloud gateway.

Notifications You must be signed in to change notification settings

UniGroupCA/external-websocket-error-sample

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Proxy External Websocket Demo

Expected Behavior

Able to proxy websocket requests to external services with spring cloud gateway.

Actual Behavior

Unable to proxy websocket requests to external services with spring cloud gateway.

How to exercise

Prerequisites

Not Working Flow

  1. Open terminal and navigate to not-working-external-websocket

  2. Run gateway service ./mvnw clean spring-boot:run

  3. Repeat Step one

  4. Attempt to establish websocket connection with this command:

     websocat 'ws://localhost:8869/websocket/echo' -H 'Pragma: no-cache' -H 'Origin: http://localhost:8869' -H 'Accept-Language: en-US,en;q=0.9' -H 'Sec-WebSocket-Key: vBAeZp3K1b+6iCx6rQSlew==' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.122 Safari/537.36 OPR/67.0.3575.53' -H 'Upgrade: websocket' -H 'Sec-WebSocket-Extensions: permessage-deflate; client_max_window_bits' -H 'Cache-Control: no-cache' -H 'Connection: Upgrade' -H 'Sec-WebSocket-Version: 13'
    
  5. Type foo and hit enter

  6. Type bar and hit enter

Expected output

foo
foo
bar
bar

Actual Output

foo
bar

Working Flow (with built changes)

  1. Make sure the code with the fix is published to maven local and the pom.xml has the correct version with the local changes in the working-external-websocket project.

  2. Open terminal and navigate to working-external-websocket

  3. Run gateway service ./mvnw clean spring-boot:run

  4. Repeat Step one

  5. Attempt to establish websocket connection with this command:

     websocat 'ws://localhost:8870/websocket/echo' -H 'Pragma: no-cache' -H 'Origin: http://localhost:8870' -H 'Accept-Language: en-US,en;q=0.9' -H 'Sec-WebSocket-Key: vBAeZp3K1b+6iCx6rQSlew==' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.122 Safari/537.36 OPR/67.0.3575.53' -H 'Upgrade: websocket' -H 'Sec-WebSocket-Extensions: permessage-deflate; client_max_window_bits' -H 'Cache-Control: no-cache' -H 'Connection: Upgrade' -H 'Sec-WebSocket-Version: 13'
    
  6. Type foo and hit enter

  7. Type bar and hit enter

Expected output

foo
foo
bar
bar

Actual output

foo
foo
bar
bar

About

Project that demonstrates the issues with trying to proxy external web socket requests using spring cloud gateway.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages