Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support http2 websockets with .net7 #1636

Open
meirkr opened this issue Feb 19, 2023 · 5 comments
Open

Support http2 websockets with .net7 #1636

meirkr opened this issue Feb 19, 2023 · 5 comments
Assignees
Labels
feature A new feature large effort Likely over a week of development effort medium effort Likely a few days of development effort needs feedback Issue is waiting on feedback before acceptance proposal Proposal for a new functionality in Ocelot waiting Waiting for answer to question or feedback from issue raiser

Comments

@meirkr
Copy link

meirkr commented Feb 19, 2023

New Feature

Support Websockets (and SignalR) redirect communication with Kestrel web server which uses .NET 7 and configured to serve http2 only.

Motivation for New Feature

Clients like Angular or .NET 7 Websocket client cannot connect when configuring the Kestrel server to host only http2.
They can, though when connecting directly to the real server, not via the Ocelot server.

Steps to Reproduce the Problem

  1. Upgrade existing SignalR service to .NET 7. Configure Kestrel to use only http2.
  2. Upgrade existing SignalR client to .NET 7
  3. Upgrade existing Ocelot to .NET 7
  4. Configure Ocelot to route to https port as http2:
  {
    "Priority": 1,
    "DangerousAcceptAnyServerCertificateValidator": true,
    "DownstreamHostAndPorts": [
      {
        "Host": "localhost",
        "Port": 5001
      }
    ],
    "DownstreamHttpVersion": "2.0",
    "DownstreamPathTemplate": "/theSignalsHub",
    "DownstreamScheme": "wss",
    "UpstreamHttpMethod": [ "Get", "Post", "PUT", "DELETE", "OPTIONS" ],
    "UpstreamPathTemplate": "/api/app/theSignalsHub"
  }
@raman-m raman-m added feature A new feature large effort Likely over a week of development effort medium effort Likely a few days of development effort proposal Proposal for a new functionality in Ocelot needs feedback Issue is waiting on feedback before acceptance waiting Waiting for answer to question or feedback from issue raiser labels May 20, 2023
@raman-m
Copy link
Member

raman-m commented May 20, 2023

Hi Meir!
Sorry for 3 months of silence here!

I believe Ocelot supports WebSocket unencrypted (aka "ws" protocol)
In docs we have the page: Websockets
From paragraphs of this page we can see that Ocelot supports WS-protocol and SignalR (legacy v1.0.2) only.
Having browse and search through source code I have found nothing related to "wss" protocol (aka WebSocket encrypted).
It seems Ocelot does not support WSS, SignalR latest.
Also, there are 0 references to Microsoft.AspNetCore.SignalR.Client package! That's strange!
Currently we are referencing web socks client via the System.Net.WebSockets namespace.
An we use the ClientWebSocket class in WebSocketsProxyMiddleware.
The System.Net.WebSockets.Client assembly is implicitly referenced by .NET 7 Web App.

Could you do these follow up actions please?

  • Upgrade your gateway .NET project with reference to Ocelot v19.0.2 aka .NET 7 release
  • Send a feedback on the version of the Microsoft.AspNetCore.SignalR.Client package please you're using in your .NET project with SignarR.
  • Give an answer when you're saying HTTP2 vs WebSocket do you mean WebSocket Secure protocol (wss://) ?

Finally,
I am afraid that Ocelot has no support for wss-protocol via "DownstreamScheme": "wss" option.

@raman-m
Copy link
Member

raman-m commented Jun 22, 2023

Hi @meirkr !

Steps to Reproduce the Problem

  1. Upgrade existing SignalR service to .NET 7. Configure Kestrel to use only http2.
  2. Upgrade existing SignalR client to .NET 7
  3. Upgrade existing Ocelot to .NET 7
  4. Configure Ocelot to route to https port as http2:

Meir, could you show us all source code plz?
Could you upload your solution to GitHub for review please?

Currently it is hard to reproduce your user case having such steps like above.
So, it is better to show old and new, both solutions.

@raman-m
Copy link
Member

raman-m commented Sep 25, 2023

Hey @meirkr !
Will PR #1377 solve your problem?
Could you verify the solution please?

@meirkr
Copy link
Author

meirkr commented Sep 27, 2023

Hi
As for the source code, unfortunately, I cannot upload it because of security reason.
I need to work on starting new projects from scratch for this purpose of demonstration.
I might do that if will be needed and will have some time.

As for the PR #1377, if it is going to be merged and a new version of Ocelot will be published with this merge, I can try to check that in my environment.

@raman-m
Copy link
Member

raman-m commented Sep 29, 2023

@meirkr commented on Sep 27

PR #1377 has been merged.
The next upcoming release is scheduled for October 1st, 2nd...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature A new feature large effort Likely over a week of development effort medium effort Likely a few days of development effort needs feedback Issue is waiting on feedback before acceptance proposal Proposal for a new functionality in Ocelot waiting Waiting for answer to question or feedback from issue raiser
Projects
None yet
Development

No branches or pull requests

2 participants