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 Load Balance using Web Socket Issue #1513

Open
rycho27 opened this issue Sep 2, 2021 · 6 comments
Open

Ocelot Load Balance using Web Socket Issue #1513

rycho27 opened this issue Sep 2, 2021 · 6 comments
Labels
accepted Bug or feature would be accepted as a PR or is being worked on bug Identified as a potential bug Health Check POC Health Checks 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 Load Balancer Ocelot feature: Load Balancer May-Jun'24 May-June 2024 release medium effort Likely a few days of development effort proposal Proposal for a new functionality in Ocelot
Milestone

Comments

@rycho27
Copy link

rycho27 commented Sep 2, 2021

Hi Ocelot Team,

Please give advice for my current issue when using Load Balance configuration on Ocelot Gateway. My websocket implementation is for Microsof SignalR on my web client

## Expected Behavior / New Feature
When one of server is down, not causing error and able redirect request to connect websocket to another server

Actual Behavior / Motivation for New Feature

1 Backend Server down causing Bad Gateway request and unable to a connect websocket to another backend server
image

Steps to Reproduce the Problem

  1. Server A installed with 1 Backend service (using .net core 3.1) and Gateway (Ocelot) service
  2. Server B installed with 1 Backend service
  3. When All service running, client able to connect websocket using gateway
  4. When Backend service is turned off on Server A and backend in server B is running, client unable to connect websocket via gateway
  5. When Backend service is turned off on Server B and backend in server A is running, client unable to connect websocket via gateway
  6. Http request is running fine.

Specifications

  • Version: Ocelot 16.0.1
  • Platform: .net Core 3.1
  • Subsystem:
  • Please see my config on my ocelot.json
 {
    "Routes": [
        {
            "DownstreamPathTemplate": "/OPUIAPI/api/{everything}",
            "DownstreamScheme": "http",
            "DownstreamHostAndPorts": [
                {
                    "Host": "bthsa1163.infineon.com",
                    "Port": 8001
                },
                {
                    "Host": "bthtsa1030.infineon.com",
                    "Port": 8000
                }
            ],
            "UpstreamPathTemplate": "/gateway/opui/api/{everything}",
            "UpstreamHttpMethod": [
                "Get",
                "Put",
                "Post"
            ],
            "AuthenticationOptions": null,
            "FileCacheOptions": {
                "TtlSeconds": 0
            },
            "LoadBalancerOptions": {
                "Type": "LeastConnection"
            }
        },
        {
            "DownstreamPathTemplate": "/eqstatoui/api/{everything}",
            "DownstreamScheme": "http",
            "DownstreamHostAndPorts": [
                {
                    "Host": "bthsa1163.infineon.com",
                    "Port": 8000
                }
            ],
            "UpstreamPathTemplate": "/gateway/eqstat/api/{everything}",
            "UpstreamHttpMethod": [
                "Get",
                "Put",
                "Post"
            ],
            "AuthenticationOptions": null,
            "FileCacheOptions": {
                "TtlSeconds": 0
            },
            "LoadBalancerOptions": {
                "Type": "LeastConnection"
            }
        },
        {
            "DownstreamPathTemplate": "/eqstatoui/signalr",
            "DownstreamScheme": "ws",
            "DownstreamHostAndPorts": [
                {
                    "Host": "bthsa1163.infineon.com",
                    "Port": 8000
                }
            ],
            "UpstreamPathTemplate": "/gateway/eqstat/signalr",
            "UpstreamHttpMethod": [
                "Get",
                "Put",
                "Post",
                "Delete",
                "Options"
            ],
            "AuthenticationOptions": null,
            "FileCacheOptions": {
                "TtlSeconds": 0
            },
            "LoadBalancerOptions": {
                "Type": "LeastConnection"
            }
        },
        {
            "DownstreamPathTemplate": "/eqstatoui/signalr/{catchAll}",
            "DownstreamScheme": "ws",
            "DownstreamHostAndPorts": [
                {
                    "Host": "bthsa1163.infineon.com",
                    "Port": 8000
                }
            ],
            "UpstreamPathTemplate": "/gateway/eqstat/signalr/{catchAll}",
            "UpstreamHttpMethod": [
                "Get",
                "Put",
                "Post",
                "Delete",
                "Options"
            ],
            "AuthenticationOptions": null,
            "FileCacheOptions": {
                "TtlSeconds": 0
            },
            "LoadBalancerOptions": {
                "Type": "LeastConnection"
            }
        },
        {
            "DownstreamPathTemplate": "/OPUIAPI/signalr",
            "DownstreamScheme": "ws",
            "DownstreamHostAndPorts": [
                {
                    "Host": "bthsa1163.infineon.com",
                    "Port": 8001
                },
                {
                    "Host": "bthtsa1030.infineon.com",
                    "Port": 8000
                }
            ],
            "UpstreamPathTemplate": "/gateway/opui/signalr",
            "UpstreamHttpMethod": [
                "Get",
                "Put",
                "Post",
                "Delete",
                "Options"
            ],
            "AuthenticationOptions": null,
            "FileCacheOptions": {
                "TtlSeconds": 0
            },
            "LoadBalancerOptions": {
                "Type": "LeastConnection"
            }
        },
        {
            "DownstreamPathTemplate": "/OPUIAPI/signalr/{catchAll}",
            "DownstreamScheme": "ws",
            "DownstreamHostAndPorts": [
                {
                    "Host": "bthsa1163.infineon.com",
                    "Port": 8001
                },
                {
                    "Host": "bthtsa1030.infineon.com",
                    "Port": 8000
                }
            ],
            "UpstreamPathTemplate": "/gateway/opui/signalr/{catchAll}",
            "UpstreamHttpMethod": [
                "Get",
                "Put",
                "Post",
                "Delete",
                "Options"
            ],
            "AuthenticationOptions": null,
            "FileCacheOptions": {
                "TtlSeconds": 0
            },
            "LoadBalancerOptions": {
                "Type": "LeastConnection"
            }
        }
    ],
    "GlobalConfiguration": {
        "BaseUrl": "https://localhost:5011"
    }
}
@nhochamvui
Copy link

so sad bro, i'm facing this issue too

@raman-m
Copy link
Member

raman-m commented Jan 13, 2024

@ggnaegi What do you think?
The author wrote strange scenarios... He switched off downstream service and then he wanted to connect successfully. 😂

@raman-m
Copy link
Member

raman-m commented Jan 13, 2024

Hi @rycho27 !
Most of routes are correct, but some routes are incorrectly defined.
You cannot load balance if 1 service, aka DownstreamHostAndPorts object!
You CAN load balance if 2+ services, or service discovery is enabled.

@ggnaegi
Copy link
Member

ggnaegi commented Jan 14, 2024

{
            "DownstreamPathTemplate": "/OPUIAPI/signalr",
            "DownstreamScheme": "ws",
            "DownstreamHostAndPorts": [
                {
                    "Host": "bthsa1163.infineon.com",
                    "Port": 8001
                },
                {
                    "Host": "bthtsa1030.infineon.com",
                    "Port": 8000
                }
            ],
            "UpstreamPathTemplate": "/gateway/opui/signalr",
            "UpstreamHttpMethod": [
                "Get",
                "Put",
                "Post",
                "Delete",
                "Options"
            ],
            "AuthenticationOptions": null,
            "FileCacheOptions": {
                "TtlSeconds": 0
            },
            "LoadBalancerOptions": {
                "Type": "LeastConnection"
            }
        }

Yes, I would expect the same behavior too, if one of the two servers is down, then the requests should be sent to the available service... We should check that.

@raman-m
Copy link
Member

raman-m commented Jan 15, 2024

@ggnaegi OK I've got it. Wonder if it was not implemented in the past... I guess also that the problem is not related to ws scheme, the issue can be reproduced with http scheme too.
I see Load Balancer limitation here when one service instance in the list is down, then Ocelot is not smart enough to find the next online service instance. Yeap, we have to filter offline service instances making requests to online ones, so making "redirects".

I see this is by design issue. And because Ocelot has no servicing Health Status feature we get this problem when Load Balancer service instances are not healthy. It will be great if we will think in terms of Microservices architecture which recommends to make quick short regular Health Check requests to all registered domain services. So, we need to design very simple Health feature... That will be great feature of Ocelot respecting Microservices philosophy.

@raman-m raman-m added bug Identified as a potential bug large effort Likely over a week of development effort medium effort Likely a few days of development effort accepted Bug or feature would be accepted as a PR or is being worked on Load Balancer Ocelot feature: Load Balancer help wanted Not actively being worked on. If you plan to contribute, please drop a note. proposal Proposal for a new functionality in Ocelot labels Jan 15, 2024
@raman-m
Copy link
Member

raman-m commented Jan 21, 2024

Duplicate of #1041

@raman-m raman-m marked this as a duplicate of #1041 Jan 21, 2024
@raman-m raman-m added the Mar-Apr'24 March-April 2024 release label Mar 16, 2024
@raman-m raman-m added this to the March'24 milestone Mar 16, 2024
@raman-m raman-m added Health Check POC Health Checks May-Jun'24 May-June 2024 release and removed Mar-Apr'24 March-April 2024 release labels May 9, 2024
@raman-m raman-m modified the milestones: March-April'24, May-June'24 May 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted Bug or feature would be accepted as a PR or is being worked on bug Identified as a potential bug Health Check POC Health Checks 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 Load Balancer Ocelot feature: Load Balancer May-Jun'24 May-June 2024 release medium effort Likely a few days of development effort proposal Proposal for a new functionality in Ocelot
Projects
None yet
Development

No branches or pull requests

4 participants