Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9194723
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T21:28:50+00:00 2026-06-17T21:28:50+00:00

I am trying to implement a chat module for my app and getting 2

  • 0

I am trying to implement a chat module for my app and getting 2 problems.

The first one is that my clients in sockets keep on disconnecting automatically.
Here’s what I am doing.

My clients get connected in a room which is dynamically created and the name of the room is a random ID that i generate.Now when a client sends a message I print a log to see how many people are there in the room and it logs “2” on the server side which is correct.But when I keep on sending messages from the clients to the server it start showing me “1” client is connected and after some time it shows me 0 clients are connected in the room.The people are automatically disconnecting why is this happening?

socket.on('SendChat',function(msgobj){      //pass the message to all people in the room.
console.log("Msg from" + msgobj.MsgSenderName + " in RoomID = "+ msgobj.RoomID);
console.log("People in room " +io.sockets.clients(msgobj.RoomID).length);
    socket.broadcast.to(String(msgobj.RoomID)).emit('RecieveChat',msgobj);  
});

This event is raised on the server side when someone sends a message from any of the client and the msgobj will contain the RoomID.So you can see I am logging number of people in the room.

The second problem is I am trying to broadcast the message which I recieve from a client.But the event at the other client is not raised.In the above code you can see the last line I used to broadcast msg to all the other clients but the events at those clients is not fired I don’t know why.Here’s what is on my client

this.Socket.on('RecieveChat',function(obj){
    self.Controller.RecieveChat(obj);
});

and here’s my log

enter image description here
You can see the RoomID is same but the people in room are leaving and this snapshot is only showing 1 people in room before that there were two people in room which then cut of to 1 and eventually 0.

EDIT:

When I change socket.broadcast.to(String(msgobj.RoomID)).emit('RecieveChat',msgobj); to socket.broadcast.emit('RecieveChat',msgobj); it starts working but not working if I emit inside a room using the to method.

Transport end (close timeout) this seems to be causing the issue.How to resolve this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T21:28:51+00:00Added an answer on June 17, 2026 at 9:28 pm

    Finally found the solution here the problem was with the version of socket.io that I was using.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to Implement chat module in my app. I am successfully done with
I am trying to implement a simple chat program in linux using bsd sockets.
I'm trying to implement a chat module in an ASP.NET MVC 4 application based
Trying to implement a MSMQ-backed WCF PubSub. I understand that net.msmq is one-way; however
I'm trying to implement a very basic chat/echo web page. When the client visits
Trying to implement google C2DM service. registrationIntent.putExtra(app, PendingIntent.getBroadcast(context,0,new Intent(), 0)); registrationIntent.putExtra(sender,example@gmail.com); context.startService(registrationIntent); Almost every
Trying to implement a UITableView of names similar to the built-in Contacts iPhone app
I'm trying to implement simple Comet chat example and for this I implemented Long
Background: I'm trying to implement a messenging system in my app, and I'm writing
I'm trying implement server code of Server-Sent Events in a generic way that any

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.