This project has moved and is read-only. For the latest updates, please go here.

Clients Not Receiving All Messages

Jun 17, 2010 at 8:26 PM

Not sure if this s the proper place to post this but here goes:

I have implemented the nito library into a server /client chat system. Basically modifing the example that was provided with the download. I have 100 to 200 clients that connect to the server and stay connected for 7+ hours. All clients connect without issue but there some are messages that are not recieved by the clients. After looking at the server output, the messages are recieved by the server and the server sends it back to the client(or says it does), but the client does not show the message as being received. I understand this can be a complex issue involving network issues but the issue is intermittent and the clients don't drop connection. Is there a sending queue size or something that can be increased to resolve this issue? Has this behavior been obsurved before and if so what possible solutions were there? 


Jun 18, 2010 at 12:35 AM

This behavior has not been observed before to my knowledge. There are no limiting factors in the Nito library; it should scale to whatever the hardware will support (and any modern computer should easily be able to handle a few hundred connections). I'd like to learn a bit more information about your scenario:
1) Are you using the Simple classes or the regular (there are chat samples for both)?
2) When a client misses a message, does it get any more messages after the missed one?

There is a low-level tracing option, though it will create a lot of data. You can enable socket-level tracing by putting this in your app.config:

<?xml version="1.0"?>
          If you leave this commented, you can capture the socket communication in realtime using TechNet's/SystemsInternals DebugView.
          If you uncomment this listener, the socket communication will go into a "Log.txt" file.
          <add name="textListener" />

      <!-- Some public methods of the Socket, TcpListener, TcpClient, and Dns classes: -->
      <source name="System.Net.Sockets" switchName="AllSwitch" tracemode="includehex" maxdatasize="1024"/>
      <add name="ErrorSwitch" value="Error"/>
      <add name="WarningSwitch" value="Warning"/>
      <add name="InformationSwitch" value="Information"/>
      <add name="VerboseSwitch" value="Verbose"/>
      <add name="AllSwitch" value="All"/>

      <!-- This listener sends output to a file named Log.txt -->
      <add name="textListener" type="System.Diagnostics.TextWriterTraceListener" initializeData="Log.txt"/>
    <trace autoflush="true" indentsize="2"></trace>

Unfortunately, higher-level tracing isn't built into the Nito sockets lib yet; planning it for the next major revision...

Jun 18, 2010 at 1:34 AM

The client does receive messages after it has "missed 1" i do a lot of logic when a message is received by the server. It tests whether its a private message a global message a connection request(not in the socket sence but authenticating against a database). The server does show that the message was recieved and sent. The sending end appends to the textbox. I dont know if it is actually sent though.

The issue is reported from a site with about 60 clients all connecting to the server over the internet from a single ip address. Not sure if that would cause any issues or not. I would think if it was an issue they would not be able to connect in the first place.   If I implement the code above will it output all socket data received by the host? 

Just a few more questions sorry if you already covered the issues.  Is there a limitation in the thread pool possibly to where a write request may dropped or skipped over because resources are not available, or is there a queue that makes sure the request will be handled when the resources become available. If this queue exists is there a size limit to where if the max is reached the request just get dropped. If so is there anyway to increase this. Also is there a good/ easy was to do a request receipt to make sure the request was sent (or is this overkill). I think I have a way to do it but any help would be greatly appreciated.  Thanks for your reply.

Jun 18, 2010 at 1:36 AM

Sorry about the double post, I am using the simple socket as my basis

Jun 19, 2010 at 5:51 AM

It's not a problem for a server to have multiple connections from a single client IP.

If you do implement the tracing in my last post, all socket communications will be logged for the whole process; that would include all client connections.

There are limitations, naturally: only a few connections can be opened at a single time, etc. However, under no circumstances would a message be skipped. If a server were overwhelmed by data, the connection would be dropped.

Since you're using the simple sockets (with keepalive packets), I think the next step would be logging. Or I could take a look at the code if you want.


Jun 20, 2010 at 12:09 AM

Could I email you my server.cs and client.cs files I would really appreciate you taking a quick look I'm sure its something simple thats causing the issue. Thanks for taking the time to look into my issue. The nito library saved me a huge amount of time and headache as I am the only one working on this project.

Jun 20, 2010 at 1:31 PM

Sure! My email address is on this page: