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.

Load Balancer not refreshing newly added nodes.

See original GitHub issue

I am working on a use case to bring up server nodes that gets added to LoadBalancedRSocketMono. Server nodes when they come up or goes down will register itself to a collection which is streamed to LoadBalancedRSocketMono. But LoadBalancedRSocketMono works only on the first registered server node when the create method was called. Below is the sample snippet. I was raising this question in community.netifi.com till last week and site is down for now. Can you please help me understand what I am doing wrong or is this a bug?

package com.rsocket.server;

import io.rsocket.Payload;
import io.rsocket.RSocketFactory;
import io.rsocket.client.LoadBalancedRSocketMono;
import io.rsocket.client.filter.RSocketSupplier;
import io.rsocket.transport.netty.client.TcpClientTransport;
import io.rsocket.util.DefaultPayload;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import java.util.stream.BaseStream;
import java.util.stream.Collectors;

public class DynamicLBClient {

    public static void main(String[] args) {
        DynamicLBClient dynamicLBClient = new DynamicLBClient();
        dynamicLBClient.callLB();

    }

    private void callLB() {

        int[] server1 = new int[] {9000};
        int[] server2 = new int[] {9001};

        Set<Set<RSocketSupplier>> suppliers = new HashSet<>();

        suppliers.add(Arrays.stream(server1)
                .mapToObj(port -> new RSocketSupplier(() -> Mono.just(RSocketFactory
                        .connect()
                        .transport(TcpClientTransport.create("localhost", port))
                        .start().doOnSubscribe(s -> System.out.println("RSocket connection established." + s))
                        .block())))
                .collect(
                        Collectors.toSet()));

        LoadBalancedRSocketMono balancer = LoadBalancedRSocketMono
                .create(Flux.fromStream(suppliers.stream()));
        Mono<Payload> monoPayload = balancer.block().requestResponse(DefaultPayload.create("test-request"));
        Payload server1Payload = monoPayload.block();
        System.out.println("Response Received Server 1---->" + server1Payload.getDataUtf8());

        suppliers.add(Arrays.stream(server2)
                .mapToObj(port -> new RSocketSupplier(() -> Mono.just(RSocketFactory
                        .connect()
                        .transport(TcpClientTransport.create("localhost", port))
                        .start().doOnSubscribe(s -> System.out.println("RSocket connection established." + s))
                        .block())))
                .collect(
                        Collectors.toSet()));

        Mono<Payload> server2Mono = balancer.log().block().requestResponse(DefaultPayload.create("test-request-second-server"));
        Payload server2Payload = server2Mono.block();
        System.out.println("Response Received- Server 2 --->" + server2Payload.getDataUtf8());

    }
}

Below lines have to be called again in order for the new server node to service the calls:

       balancer = LoadBalancedRSocketMono
                .create(Flux.fromStream(suppliers.stream()));

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
OlegDokukacommented, Oct 27, 2020

@pckeyan feel free to open a new issue if you spot any other problems related to the new implementation

1reaction
OlegDokukacommented, Jun 1, 2020

Yeah. This is a bug. So it is not a future but rather a bug so it should be fixed

Read more comments on GitHub >

github_iconTop Results From Across the Web

Content not updating after adding new nodes to the Load ...
To restart all nodes at the same time: 1. Re-save the web.config file on one node. - Do not access the website on...
Read more >
Nodebalancer not updated when adding new nodes to the ...
When adding/removing nodes in a cluster, existing Nodebalancer endpoints should be updated to reflect the change.
Read more >
Troubleshoot your Network Load Balancer
The following information can help you troubleshoot issues with your Network Load Balancer. A registered target is not in service. If a target...
Read more >
Cloud Load Balancers troubleshooting - - Rackspace
If a load balancer suddenly stops working, it might be due to changes on the nodes attached to the load balancer. Review recent...
Read more >
Troubleshoot External HTTP(S) Load Balancing - Google Cloud
Compression isn't working ... HTTP(S) Load Balancing does not compress or decompress responses itself, but it can serve responses generated by your backend ......
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