Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

117
Visualizações
How can you dynamically switch SignalR hubs

I have 2 hubs that live on 2 different servers. Ideally I would like my series of webpages to connect to attempt to connect to 1 of these hubs, then if it fails switch to the other hub. Is this possible at all.

I can't use the traditional method to connecting to the hub like so:

<script id="hubScript" src="IP:port/signalr/hubs"></script>
    $.connection.hub.url = SIGNALR_HUB_SERVER_1;
    srv = $.connection.tcpHub;

since I don't know which hub I will be connecting to, or which hub will be alive.

Example of code that I have tried for reference

   if (document.head.getElementsByTagName("script").item(i).src == SIGNALR_HUB_SERVER_1 + "/hubs") {
        $.connection.hub.url = SIGNALR_HUB_SERVER_1;
   }
   else if(document.head.getElementsByTagName("script").item(i).src == SIGNALR_HUB_SERVER_2 + "/hubs") {
        $.connection.hub.url = SIGNALR_HUB_SERVER_2;
   }

When I try and connect using this code I get the error: "Error loading hubs. Ensure your hubs reference is correct". This is because my script tag that contains the url is not the same as the url that I am trying to connect to.

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda