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

reconnect to new hubServerUrl #192

Closed
behnam-basketasia opened this issue Apr 23, 2019 · 5 comments
Closed

reconnect to new hubServerUrl #192

behnam-basketasia opened this issue Apr 23, 2019 · 5 comments

Comments

@behnam-basketasia
Copy link

In my project, I set hubServerUrl in the main.js, but i want to ping many server and then connect to best one, i need to disconnect from previous hubServerUrl and then connect to new hubServerUrl. How can i handle this changing hubServerUrl? Is it possible to change it base on an event?
i try to use it for changing url but cant connect to new one:

dotnetify.hub.init()  
dotnetify.hubServerUrl = "http://www.domain.com";

@dsuryd
Copy link
Owner

dsuryd commented Apr 24, 2019

It's not currently set up for your use case. Can you just determine the best server before making the initial connect?

@behnam-basketasia
Copy link
Author

yes i cant, but my purpose is that i want to check list of servers that get from Backend in an interval and then check best server base on user internet speed and want to change the connection, is there any recommendation for solving this problem? or any update to handle it?

@dsuryd dsuryd transferred this issue from dsuryd/dotNetify-react-template Apr 24, 2019
@mason-chase
Copy link
Contributor

This is very useful feature for us if we can have it, a server may go down or get overloaded, so client can determine a better or alternative server at any given time in multi-server environment.

This would eliminate the need for GLSB's such as Amazon Route 53's latency based dns, not to mention with DNS we may not quickly and seamlessly switch user to a new working server as DNS would take a while to update.

@dsuryd
Copy link
Owner

dsuryd commented Apr 25, 2019

Try this:

Add the following to main.js, and then you only need to set dotnetify.hubServerUrl to switch server.

import dotnetify from 'dotnetify';

Object.defineProperty(dotnetify, 'hubServerUrl', {
  get: () => dotnetify.hub.url,
  set: url => {
    dotnetify.hub.url = url;
    if (dotnetify._hub) {
      dotnetify._hub = null;
      dotnetify.startHub();
    }
  }
});

@behnam-basketasia
Copy link
Author

I'm so grateful for your help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants