Author Topic: Random ID_CONNECTION_LOST and how to figure it out?  (Read 17904 times)

Trevor

  • Jr. Member
  • **
  • Posts: 77
  • Karma: 2
    • View Profile
    • LackeyCCG: Play any CCG online
Random ID_CONNECTION_LOST and how to figure it out?
« on: October 27, 2010, 12:37:01 AM »
I have a game with a server that hosts multiple clients. All of the clients have very stable connections, but occasionally, some clients will get the ID_CONNECTION_LOST notice and get disconnected from the server. Can someone give me some tips on how to troubleshoot what's causing the disconnects? I haven't been disconnected personally testing from machines on my LAN, but at least 2 people have reported multiple times when they just disconnect for no apparent reason after being connected successfully for hours.

I know that the server isn't going offline, because while 1 client may get disconnect, everyone else stays connected fine.

Are there any helpful error codes that I can access somehow?

Thanks.

btw, I think Raknet is pretty darn awesome. Nice work.
« Last Edit: October 27, 2010, 01:46:35 AM by Trevor »

Rak'kar

  • Administrator
  • Hero Member
  • *****
  • Posts: 6895
  • Karma: 291
    • View Profile
    • RakNet
Re: Random ID_CONNECTION_LOST and how to figure it out?
« Reply #1 on: October 27, 2010, 11:49:00 AM »
Thanks for the positive comments. There have been a couple of fixes for this issue recently. Please update to SVN and let me know if it still happens
http://raknet.svn.sourceforge.net/viewvc/raknet/branches/RakNet4/

Trevor

  • Jr. Member
  • **
  • Posts: 77
  • Karma: 2
    • View Profile
    • LackeyCCG: Play any CCG online
Re: Random ID_CONNECTION_LOST and how to figure it out?
« Reply #2 on: October 28, 2010, 05:02:17 PM »
I just updated to the very latest version of RakNet and people still get the random disconnect apparently for no reason. Any suggestions on how I can track down these sorts of disconnects?

Rak'kar

  • Administrator
  • Hero Member
  • *****
  • Posts: 6895
  • Karma: 291
    • View Profile
    • RakNet
Re: Random ID_CONNECTION_LOST and how to figure it out?
« Reply #3 on: October 28, 2010, 06:43:04 PM »
What operating system is this?

Is the application small that you can send it to me?

Otherwise, please run the PacketFileLogger plugin and send me the output. Please clearly indicate which file goes to which system, and what the IP addresses of each system are.

Trevor

  • Jr. Member
  • **
  • Posts: 77
  • Karma: 2
    • View Profile
    • LackeyCCG: Play any CCG online
Re: Random ID_CONNECTION_LOST and how to figure it out?
« Reply #4 on: October 29, 2010, 12:38:30 AM »
He is running Windows 7. He's the same guy who just ran his windows updater and no longer needs to start as an admin.

Our test setup was this: I was hosting a server and only he connected to it. While connected we didn't do anything (other than the server sending a pulse to the client every 10 seconds). He got disconnected at 3:23 PM, 5:33 PM, 5:56 PM, 8:13 PM, 9:53 PM.

Here is a link to my program. http://www.lackeyccg.com/LackeyCCGAlpha.zip
To connect to my server, run the .exe, click on the Server tab, type in my IP 66.65.20.193 and my port 25712 and then hit the "Connect to server from IP" button.

I am going to try to install that PacketFileLogger plugin now.

Trevor

  • Jr. Member
  • **
  • Posts: 77
  • Karma: 2
    • View Profile
    • LackeyCCG: Play any CCG online
Re: Random ID_CONNECTION_LOST and how to figure it out?
« Reply #5 on: October 29, 2010, 09:01:36 AM »
Just to make sure the disconnects were not caused by some mistake I did with my implementation of RakNet functions, I used the chat server sample.

These are exactly the files in the latest posted RakNet 4.0 Beta 7, except for the 4 lines I added to include PacketFileLogger.
http://lackeyccg.com/Chat%20Example%20Server.cpp
http://lackeyccg.com/Chat%20Example%20Client.cpp

I ran as the server on my mac (latest version) and he ran the client with windows 7. We both have very stable internet connections. Here are our log files.
http://lackeyccg.com/ServerOutput_0.csv
http://lackeyccg.com/ClientOutput_270301818.csv

I launched the server, and he connected, and we did nothing else. Eventually he got a ID_CONNECTION_LOST message, at which point he emailed me his ClientOutput_270301818.csv.
Server IP: 66.65.20.193 Port:25713
Looking at the logs, I see no "ID_CONNECTION_LOST" message there, but he says he was given that message in his console.

Correct me if I am wrong, but this is not the intended behavior of Chat Example Server.cpp and RakNet, right? A connection should remain until it is closed, right? I didn't enable some sort of time out function I assume.

If there is anything else I can do to test the problem, please let me know.
« Last Edit: October 29, 2010, 09:20:33 AM by Trevor »

Rak'kar

  • Administrator
  • Hero Member
  • *****
  • Posts: 6895
  • Karma: 291
    • View Profile
    • RakNet
Re: Random ID_CONNECTION_LOST and how to figure it out?
« Reply #6 on: October 29, 2010, 09:43:06 AM »
Thanks for providing this info. I am looking at it now.

Rak'kar

  • Administrator
  • Hero Member
  • *****
  • Posts: 6895
  • Karma: 291
    • View Profile
    • RakNet
Re: Random ID_CONNECTION_LOST and how to figure it out?
« Reply #7 on: October 29, 2010, 10:00:34 AM »
Please confirm you have this version of GetTime.cpp, and update if you do not. I'm pretty sure that you have an older version that had a thread-safety issue, causing disconnects
http://raknet.svn.sourceforge.net/viewvc/raknet/branches/RakNet4/Source/GetTime.cpp

Trevor

  • Jr. Member
  • **
  • Posts: 77
  • Karma: 2
    • View Profile
    • LackeyCCG: Play any CCG online
Re: Random ID_CONNECTION_LOST and how to figure it out?
« Reply #8 on: October 29, 2010, 10:08:50 AM »
Please confirm you have this version of GetTime.cpp, and update if you do not. I'm pretty sure that you have an older version that had a thread-safety issue, causing disconnects
http://raknet.svn.sourceforge.net/viewvc/raknet/branches/RakNet4/Source/GetTime.cpp
I do indeed have a different GetTime.cpp. A day or so ago I downloaded the "Download GNU tarball" link and replaced the files I had with them, or so I thought. I am redownloaded the files and recompiling everything. I'll run the same test again and see if that fixes things.

Rak'kar

  • Administrator
  • Hero Member
  • *****
  • Posts: 6895
  • Karma: 291
    • View Profile
    • RakNet
Re: Random ID_CONNECTION_LOST and how to figure it out?
« Reply #9 on: October 29, 2010, 10:13:49 AM »
It was probably my fault. I have multiple repositories and may have forgotten to check in the public one. Hope that fixes it for you.

Trevor

  • Jr. Member
  • **
  • Posts: 77
  • Karma: 2
    • View Profile
    • LackeyCCG: Play any CCG online
Re: Random ID_CONNECTION_LOST and how to figure it out?
« Reply #10 on: October 29, 2010, 10:34:28 AM »
I see your note about GetTime.cpp at http://raknet.svn.sourceforge.net/viewvc/raknet/branches/RakNet4/Source/GetTime.cpp?view=log
"Fix GetTime not being threadsafe on Linux, causing disconnections"
Does that apply also to Mac OSX with its BSD kernel?

I notice that when I run the server on windows, the csv log file for the server includes a time in the first column. When I run the same code on my mac for the server, the first column for time is blank. This seems like a bug related to GetTime.cpp, and specifically how things are handled on the mac.
« Last Edit: October 29, 2010, 11:07:58 AM by Trevor »

Rak'kar

  • Administrator
  • Hero Member
  • *****
  • Posts: 6895
  • Karma: 291
    • View Profile
    • RakNet
Re: Random ID_CONNECTION_LOST and how to figure it out?
« Reply #11 on: October 29, 2010, 11:29:40 AM »
Quote
I see your note about GetTime.cpp at http://raknet.svn.sourceforge.net/viewvc/raknet/branches/RakNet4/Source/GetTime.cpp?view=log
"Fix GetTime not being threadsafe on Linux, causing disconnections"
Does that apply also to Mac OSX with its BSD kernel?

It does if it is running the Linux code. It's either that or the Windows version, so I assume it's the Linux code :)

The time isn't written on the Mac because this function has it ifdefed out:
PacketLogger::GetLocalTime(char buffer[128])

It's idefed out because I didn't know how to write the equivalent code for Linux based platforms so just had it return nothing. If you know how and could provide that code I'd appreciate it.


Trevor

  • Jr. Member
  • **
  • Posts: 77
  • Karma: 2
    • View Profile
    • LackeyCCG: Play any CCG online
Re: Random ID_CONNECTION_LOST and how to figure it out?
« Reply #12 on: October 29, 2010, 04:54:00 PM »
Even after updating GetTime.cpp, there still is a disconnect.

http://lackeyccg.com/ServerOutput_0X.csv
http://lackeyccg.com/ClientOutputX_287437826.csv

Server IP: 66.65.20.193
Client IP: 69.156.60.105

I still don't see anything in those logs about ID_CONNECTION_LOST. Shouldn't I, if I get the message in the console?
« Last Edit: October 29, 2010, 05:09:09 PM by Trevor »

Trevor

  • Jr. Member
  • **
  • Posts: 77
  • Karma: 2
    • View Profile
    • LackeyCCG: Play any CCG online
Re: Random ID_CONNECTION_LOST and how to figure it out?
« Reply #13 on: October 29, 2010, 05:03:18 PM »
The time isn't written on the Mac because this function has it ifdefed out:
PacketLogger::GetLocalTime(char buffer[128])

It's idefed out because I didn't know how to write the equivalent code for Linux based platforms so just had it return nothing. If you know how and could provide that code I'd appreciate it.


I'm not sure if this is what you want, but this is what I use for time on my mac:

Code: [Select]
const char* GetRakDateAndTime()//10/29/10 08:46:28.254340
{// Returns a string as "MM/DD/YY HH:MM:SS.SSSSSS"
string TempString("");
#ifndef WindowsBuild
// Get date
time_t secs=time(NULL);
struct tm *t=localtime(&secs);

#define kDateSeperator '/'
char Buffer[32];

cout << "t->tm_mon:" << t->tm_mon << endl;
if(t->tm_mon+1<10)
sprintf(Buffer,"0%i%c",t->tm_mon+1,kDateSeperator); // If the month a single digit, add 0
else
sprintf(Buffer,"%i%c",t->tm_mon+1,kDateSeperator);
TempString.append(Buffer);

if(t->tm_mday<10)
sprintf(Buffer,"0%i%c",t->tm_mday,kDateSeperator); // If the day is a single digit, add 0
else
sprintf(Buffer,"%i%c",t->tm_mday,kDateSeperator);
TempString.append(Buffer);
if(t->tm_year-100<10) // year-100 is the last 2 digits of the year
sprintf(Buffer,"0%i ",t->tm_year-100); // If the year a single digit, add 0
else
sprintf(Buffer,"%i ",t->tm_year-100);
TempString.append(Buffer);
// Get time with milliseconds
struct timeval  tv;
struct timezone tz;
struct tm      *tm;
 
gettimeofday(&tv, &tz);
tm = localtime(&tv.tv_sec);

#define kTimeSeperator ':'
if(tm->tm_hour<10)
sprintf(Buffer,"0%i%c",tm->tm_hour,kTimeSeperator); // If the hour is a single digit, add 0
else
sprintf(Buffer,"%i%c",tm->tm_hour,kTimeSeperator);
TempString.append(Buffer);

if(tm->tm_min<10)
sprintf(Buffer,"0%i%c",tm->tm_min,kTimeSeperator); // If the minute is a single digit, add 0
else
sprintf(Buffer,"%i%c",tm->tm_min,kTimeSeperator);
TempString.append(Buffer);

if(tm->tm_sec<10)
sprintf(Buffer,"0%i.",tm->tm_sec); // If the second is a single digit, add 0
else
sprintf(Buffer,"%i.",tm->tm_sec);
TempString.append(Buffer);

sprintf(Buffer,"%d",tv.tv_usec);
TempString.append(Buffer);
#endif
return TempString.c_str();
}
« Last Edit: November 01, 2010, 06:15:42 AM by Trevor »

Rak'kar

  • Administrator
  • Hero Member
  • *****
  • Posts: 6895
  • Karma: 291
    • View Profile
    • RakNet
Re: Random ID_CONNECTION_LOST and how to figure it out?
« Reply #14 on: October 29, 2010, 09:16:04 PM »
Even after updating GetTime.cpp, there still is a disconnect.

http://lackeyccg.com/ServerOutput_0X.csv
http://lackeyccg.com/ClientOutputX_287437826.csv

Server IP: 66.65.20.193
Client IP: 69.156.60.105

I still don't see anything in those logs about ID_CONNECTION_LOST. Shouldn't I, if I get the message in the console?

The packet logs don't write ID_CONNECTION_LOST because that is generated and returned locally.

What I see on the server output is that everything is normal until about line 2896. Then all of the sudden, the same ID_CONNECTED_PING repeatedly arrives (datagram number 168). There are about 200 of these in a row.

This is a longshot, but it might be caused by a bug I just fixed today. There was no minimum resend threshhold for resends, which could cause a flood of packets on a LAN. If this update doesn't fix it, then I would log to the screen instead (PacketLogger instead of PacketFileLogger). Then when you notice a bunch of ID_CONNECTED_PING arriving, but no ID_CONNECTED_PONG being sent back, put a breakpoint in RakPeer.cpp line 5456

Code: [Select]
else if ( (unsigned char)data[0] == ID_CONNECTED_PING && byteSize == sizeof(unsigned char)+sizeof(RakNet::Time) )
And see if it gets into the scope of that condition. If it wasn't getting in there for some reason then the problem is higher up, but at least that gives me a starting point to think about.

Also, at line 3089, there's just a bunch of junk info in the logs which goes on for a while. The local IP is UNASSIGNED_SYSTEM_ADDRESS while the sender is 127.0.0.1:58443. Are you sending data from that port/IP to yourself? It's marked as raw data, meaning it could come from any program and is basically just garbage to RakNet.

SVN also contains an update for fixing the packet logger to write the datagram number for outgoing messages.

SVN Path:
http://raknet.svn.sourceforge.net/viewvc/raknet/branches/RakNet4/