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

182
Visualizações
getOpenSessions() giving empty [ ] value

I am trying save the sessions in Set allSession , but the getOpenSessions() method creating an empty array. My code looks like -

@OnOpen
public void onOpen(Session session){
    System.out.println(session.getId() + " has opened a connection");
    System.out.println(" Session: "+session.getOpenSessions());
    try {
        session.getBasicRemote().sendText("Connection Established");
    } catch (IOException ex) {
        ex.printStackTrace();
    }
}

So, It's giving me an result -

1 has opened a connection

Session []

Can anyone suggest what is the exact problem here?

over 4 years ago · Santiago Trujillo
3 Respostas
Responde à pergunta

0

Sorry for the delayed answer. The bug was tomcat version 8.0. Tomcat 7 is more stable. I am using this from 3,4 months but session related issue is coming. Hope this information will help you.

over 4 years ago · Santiago Trujillo Relatório

0

i got the same problem...but when i used the method in the @onMessage annotation method ..it works fine...the set is showing the elements...

over 4 years ago · Santiago Trujillo Relatório

0

this worked!

    @OnMessage
    public String echo(String msg) throws IOException {
   
        Set<Session> set1 =  wsSession.getOpenSessions();
        
        System.out.println("set:  "+set1);
        
         Iterator<Session> iter = set1.iterator();
         
         while(iter.hasNext()) {
             
             
               System.out.println("entered inside while");
               
         }
    }
over 4 years ago · Santiago Trujillo 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