Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

173
Views
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 answers
Answer question

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 Report

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!