[ENet-discuss] Possible bug - some peers mysteriously disconnecting - help needed

Kresimir Cosic kreso at galacticmag.com
Tue Jan 8 08:43:40 PST 2008

Hi all!

First, sorry for the long post, but the issue might be complex.

I have been using ENET for my game www.galacticmag.com for 2 years. 
Since start, I had experienced some strange disconnects. Other than 
this, the game and the server are working just fine, it's a 
monolythic server and in the last year, other than disconnects, 
there are less than 2 bugs monthly, mostly minor stuff.

Now, as I said, I think I have a problem with ENET, but I realize 
that I might be wrong.

The problem is that some peers(players) get disconnected for no 
apparent reason, the enet connection just breaks down. And it 
happens only to a single user at a time, while the 50 other 
connected users remain unaffected.

I tried, in the last two years, to find a source of this problem, 
but the only thing that could cause the problem seems to be Enet.

There is always that question: Why other Enet users are not getting 
the same problem. Perhaps it's because my game requires players to 
stay connected for more than hour, so average connection length is 
about 50 minutes. If connection breaks, this is immediately noticed 
by players because they lose a game.

If the average connection length was lower, there would be lower 
percentage of broken connections and this might go unnoticed by 
other Enet users. Or perhaps I'm just wrong.

So I recently installed a packet sniffer and captured a short Enet 
communication (this log will be provided) which exhibits the problem.

I tried to analyze the log, but this is quite complex, and I 
probably wont be able to conclude anything since I don't know enet 
well enough.

So I thought maybe someone knowledgeable could help by analyzing the 
log, and perhaps fix the error in the Enet if it exists.

Well, if anyone has time and knowledge I would appreciate the 
help... but I understand it is a complex issue and that it might be 
too much time consuming.

	Kresimir Cosic

The log:

Enet version: 1.0

Log can be downloaded from:

I think this is some kind of standard sniffer format, but I can view 
and analyze it quite nicely with Wireshark.

It's really short, total 207 packets, but the client is disconnected 
after first 139. Total length is 6 minutes.

Server's port is 29370, IP

First 20 packets contain one successful Enet connection where user 
named LMORRISON creates new account.

Afterwards, there is a second connection that was broken unexpectedly.

Keepalive is implemented on application layer, the client sends the 
keepalive packet after 5 seconds of sending nothing. The keepalive 
packet consists of a single byte containing the value 5.

Server database reports last keepalive packet was received at the 
moment corresponding to approx. 175 seconds into log file.

At the start of the connection, clients sends it's login data, 
encrypted, and then communicates lobby chat data with the server. 
This lasts up to 5 seconds. The server game event log file confirms 
that afteward this, except for the keepalive packets, no other data 
was received from client.

Also, not contained in the log file (filtered it out), the client 
was clearly disconnected at timestamp 191 because at that point I 
received another connection attempt from same IP address, same 
username, but different port, meaning that user has restarted the 
client and is attempting to reconnect. An then another connection 
attempt at timestamp 285. Those were refused by server (no double 
logins policy). This also shows that it was probably not the client 
simply disconnectiong from internet.

Also, the client's diagnostics show that it is not using NAT.

Additional notes:

I actually changed Enet a bit (yes, well..) , but I had the 
disconnects before I did the change, in fact, it was attempt to fix 
this disconnects by giving clients more time before Enet decides to 
drop them, and with more aggressive packet resend strategy. The 
changes (made a year ago) are:
-Client: connection is dropped after a fixed time of 150 seconds of 
server not acknowledging a packet, and packet resend time is never 
higher than 7 seconds.
-Server: connection is dropped on application layer after 175 
seconds of no-keepalive, resend time always less than 7 seconds.
Removed Enet built-in keepalive/ping (calls to enet_peer_ping 
disabled) on both client and server.

I think that those changes are minimal and could not interfere with 
functioning of Enet.

More information about the ENet-discuss mailing list