Helloes good people of Stack Overflow,
I have a .NET client-server application running with a few hundred of clients. The project was migrated from VB6 to .NET about a year ago and it's a platform for card/board games.
Although I'll be trying to give as much detail as I can below, the problem is getting a channel frozen when there are 40-70 players inside.
Architecture
1. Server (.NET 4.0)
2. Client (.NET 2.0)
When there are 40+ clients connected to a single channel, it starts to get frozen totally randomly (or that's what we have right now, got no evidance or enough datas to point out what's totally wrong). We really don't think network traffic is the issue (not quite sure yet) since we have tried it on different server machines with various setups. All the server machines we have used are capable of handling that much of process hardware-wise. So it is about the approach and what's going on code side.
The reason why we are struggling to address the issue is we are not exactly sure what could be causing it. Please check out the following example:
System A has 55 people online in their Channel #1 and it doesn't get frozen anyhow. System A uses A1 IP and the channel is on 16xxx port.
System B has 25 people online in their Channel #4 and it gets frozen like one or two minutes randomly. System B uses B1 IP and 18xxx for the channel port. It's on the same machine with System A which doesn't get frozen.
As a conclusion, it looks irrelevant with the number of online people but it occurs more often when numbers rise.
We tried rolling an Application.DoEvents() in an endless do-loop in Channel project thinking that some X process causing the channel to go frozen state for a few minutes, thus resulting a pause in channel. Then it performs every action which was queued while it was frozen, in a few seconds. CPU usage is averagely between 7%-20% per channel, it looks like it is getting better. However it was no permanant and effective solution.
Things we suspect:
Server info
Intel Xeon X3460 2.80GHz
16 GB RAM
64-bit Windows Server 2008 Enterprise
I know it is impossible to address the issue without seeing the whole code, but I regret that I'm unable to post the codes. Instead I'm looking for an idea to put me into some direction. However we are happy to share any other info for resolving this problem.
Thanks to everyone helping!
We had a very similar problem on a very similar app (ours pushed out stats to ~1300 users).
My best guess is that on your TCPClient, you have an infinite timeout set. This is, unfortunately, the default behavior. So, when TCPClient blocks on a read, it sometimes gets completely frozen.
Set the timeout to 30 seconds (or something more suitable to your situation).
TcpClient newClient = incoming.AcceptTcpClient();
newClient.NoDelay = true; // Send & receive immediately, even when the buffers aren't full
newClient.ReceiveTimeout = 30000;
newClient.SendTimeout = 30000;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With