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

Ocelot 16.0.1 routing failed when SignalR during WebSocket handshake #1283

Closed
xingwen1987 opened this issue Jul 8, 2020 · 6 comments
Closed
Assignees
Labels
bug Identified as a potential bug help wanted Not actively being worked on. If you plan to contribute, please drop a note. 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 needs validation Issue has not been replicated or verified yet question Initially seen a question could become a new feature or bug or closed ;) waiting Waiting for answer to question or feedback from issue raiser

Comments

@xingwen1987
Copy link

xingwen1987 commented Jul 8, 2020

Steps to Reproduce the Problem

1.Use the recommended configuration of SignalR in the official document
image
2.Make sure the SignalR server is available
image
image
image
3.Switch Url to Ocelot's route for SignalR, the following exception occurred
image
image

  • Version:16.0.1
  • Platform:.Net Core 3.1
@ssulleyymmann
Copy link

hi,
I am using service discovery, consul and signalr.
I have same problem. Is there any improvement, update or suggest?

@jlukawska
Copy link
Contributor

UnableToFindDownstreamRouteError when using 16.0.1 version is often caused by "ReRoutes" word in ocelon.json file. The 16.0.1 version requires the word "Routes".

@ssulleyymmann
Copy link

hi jlukawska,

I'm already using it as "routes" but it doesn't work.

signalr js =>
const connection = new signalR.HubConnectionBuilder()
.withUrl("http://localhost:5000/socket/xhub", {
skipNegotiation: true,
transport: signalR.HttpTransportType.WebSockets
})
.configureLogging(signalR.LogLevel.Trace)
.build();

startup.cs
public void ConfigureServices(IServiceCollection services)
{
services
.AddOcelot(Configuration)
.AddConsul()
.AddConfigStoredInConsul();

        services.AddSwaggerForOcelot(Configuration);
    }

    public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
    {
        app.UseWebSockets();
        app.UseOcelot().Wait();
    }

ocelot cong =>
"Routes": [
{
"DownstreamPathTemplate": "/xhub",
"DownstreamScheme": "http",
"ServiceName": "x.socket",
"SwaggerKey": "x.api.socket",
"UpstreamPathTemplate": "/socket/xhub",
"UpstreamHttpMethod": [ "GET", "POST", "PUT", "DELETE", "OPTIONS" ],
"LoadBalancerOptions": {
"Type": "LeastConnection"
}
}
]

browser consol =>
[2020-09-30T08:30:51.216Z] Debug: Starting HubConnection.
Utils.ts:178 [2020-09-30T08:30:51.217Z] Debug: Starting connection with transfer format 'Text'.
Utils.ts:178 [2020-09-30T08:30:51.218Z] Trace: (WebSockets transport) Connecting.
WebSocketTransport.ts:64 WebSocket connection to 'ws://localhost:5000/socket/xhub' failed: Error during WebSocket handshake: Unexpected response code: 500
(anonymous) @ WebSocketTransport.ts:64
Utils.ts:168 [2020-09-30T08:30:51.318Z] Error: Failed to start the connection: Error: There was an error with the transport.
Utils.ts:178 [2020-09-30T08:30:51.319Z] Debug: HubConnection failed to start successfully because of error 'Error: There was an error with the transport.'.
x.js:60 Error: There was an error with the transport.
at WebSocket.webSocket.onerror (WebSocketTransport.ts:85)

@xingwen1987
Copy link
Author

hi jlukawska,

I'm already using it as "routes" but it doesn't work.

signalr js =>
const connection = new signalR.HubConnectionBuilder()
.withUrl("http://localhost:5000/socket/xhub", {
skipNegotiation: true,
transport: signalR.HttpTransportType.WebSockets
})
.configureLogging(signalR.LogLevel.Trace)
.build();

startup.cs
public void ConfigureServices(IServiceCollection services)
{
services
.AddOcelot(Configuration)
.AddConsul()
.AddConfigStoredInConsul();

        services.AddSwaggerForOcelot(Configuration);
    }

    public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
    {
        app.UseWebSockets();
        app.UseOcelot().Wait();
    }

ocelot cong =>
"Routes": [
{
"DownstreamPathTemplate": "/xhub",
"DownstreamScheme": "http",
"ServiceName": "x.socket",
"SwaggerKey": "x.api.socket",
"UpstreamPathTemplate": "/socket/xhub",
"UpstreamHttpMethod": [ "GET", "POST", "PUT", "DELETE", "OPTIONS" ],
"LoadBalancerOptions": {
"Type": "LeastConnection"
}
}
]

browser consol =>
[2020-09-30T08:30:51.216Z] Debug: Starting HubConnection.
Utils.ts:178 [2020-09-30T08:30:51.217Z] Debug: Starting connection with transfer format 'Text'.
Utils.ts:178 [2020-09-30T08:30:51.218Z] Trace: (WebSockets transport) Connecting.
WebSocketTransport.ts:64 WebSocket connection to 'ws://localhost:5000/socket/xhub' failed: Error during WebSocket handshake: Unexpected response code: 500
(anonymous) @ WebSocketTransport.ts:64
Utils.ts:168 [2020-09-30T08:30:51.318Z] Error: Failed to start the connection: Error: There was an error with the transport.
Utils.ts:178 [2020-09-30T08:30:51.319Z] Debug: HubConnection failed to start successfully because of error 'Error: There was an error with the transport.'.
x.js:60 Error: There was an error with the transport.
at WebSocket.webSocket.onerror (WebSocketTransport.ts:85)

dotnet/aspnetcore#10440

this issue give me some idea, in localhost, ocelot works fine, but in docker, route match faild

this is my new issue

#1364

@raman-m
Copy link
Member

raman-m commented May 29, 2023

Hi @xingwen1987 !

Version: 16.0.1
Platform: .NET Core 3.1

I guess such spec is outdated during this 2023 year.
Could you upgrade your solution to .net7 and v19.0.2 please?
And let us know the current behavior of the bug please! 🙏


Another question

this is my new issue
#1364

Thanks for creation new user scenario!
But Is 1364 a duplicate of this 1283 issue?
I see they are both related to SignarR problems, right?
Are you sure they are different root cause issues?

@raman-m raman-m added bug Identified as a potential bug help wanted Not actively being worked on. If you plan to contribute, please drop a note. question Initially seen a question could become a new feature or bug or closed ;) large effort Likely over a week of development effort medium effort Likely a few days of development effort needs validation Issue has not been replicated or verified yet needs feedback Issue is waiting on feedback before acceptance waiting Waiting for answer to question or feedback from issue raiser labels May 29, 2023
@raman-m
Copy link
Member

raman-m commented Jun 15, 2024

Outdated issue ❗

@raman-m raman-m closed this as not planned Won't fix, can't repro, duplicate, stale Jun 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Identified as a potential bug help wanted Not actively being worked on. If you plan to contribute, please drop a note. 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 needs validation Issue has not been replicated or verified yet question Initially seen a question could become a new feature or bug or closed ;) waiting Waiting for answer to question or feedback from issue raiser
Projects
None yet
Development

No branches or pull requests

4 participants