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

261
Visualizações
socket.io - How to check if the client has connected from browser

What is the most reliable way to detect if some one has directly connect to my socket connection instead of browser? I know that we can bypass all of that but I realized some WebSockets like tradingView return 403 when connecting directly from socket.io-client but works fine from browser.

How does it detect that And How can I implement that for my own socket.io server?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I'm not sure how to get device/browser/app the client is connected with but I managed to do something like that using handshake query of socket.io. I needed to distinguish between admin and client so in my client side I used this code:

 const socket = io({
        query: {
            isAdmin: true,
            name: "GetSub Admin"
        },
        // path: '/websockets',
        resource: '/websockets'
    });

and on the server side I used

if (client.handshake.query.isAdmin == 'true') {
            admins.push({
                id: client.id,
                name: client.handshake.query.name
            });
        }
        else {
            users.push({
                id: client.id,
                name: client.handshake.query.name
            });

maybe this will help you.

about 4 years ago · Juan Pablo Isaza Relatório
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