I'm really out of my wits with this. I'm creating an app to send data between computers, I've already raised an issue here a while back.
In essence, the connection is randomly terminated. Mid Send
and Read
on client and server respectively. I have made sure I am not calling any disconnect method on either. The WriteResult
just returns as Disconnected
at a random point during the process. I have considered Keepalives to be the cause and once disabled, it worked once, but I then reenabled and when I disabled again, it no longer worked. I am now at the state, where I send the same data over and over and there is seemingly a random % chance of the client or server disconnecting during the data transfer (unsure as to which one causes it). So I do not believe the Keepalives to be the cause of the problem, but they now are disabled on both.
The problem is on this branch of my app. The problem is centralized to the TransferClient and its SendFile
function, which does the actual file data transfer. There, there is result = client.Send(buffer);
and this result sometimes equals WriteResultStatus.Disconnected
, because the client
disconnects.
For reference, this is my server class .
Once again, I'm not calling for any disconnects myself. I have even completely disabled my disconnecting method TerminateConnection
and it still happens.
Would appreciate any help, as this is a bit urgent and I really can't find anything else to try. I was sure it must be a bug in my code, but I have tried everything I could think off and it really doesn't seem like it, so maybe the Keepalives are enabled even with Keepalive.EnableTcpKeepAlives = false
?
I should add that Keepalives shouldn't even have time to fail, as they were set to the default 5,5,5 for the values before I disabled them, and the error happens within the first 1-2 seconds of the connection, usually less. But I have also tested the Keepalives to detect a ethernet cable disconnect practically immediately, so I'm not sure how they work exactly.
Also from my test it seems that the client disconnects from the server, not the other way around, as the client's Events_ClientDisconnected
seems to be called earlier then the server's.