Connection failed: the semaphore timeout has expired

Having trouble with the game? Report issues and get help here. Read this first!

Moderator: Forum Moderators

Forum rules
Before reporting issues in this section, you must read the following topic:
Tad_Carlucci
Inactive Developer
Posts: 503
Joined: April 24th, 2016, 4:18 pm

Re: Connection failed: the semaphore timeout has expired

Post by Tad_Carlucci »

Yea! I can force this issue to occur on my local network.

To reproduce I started wesnothd on my Linux box, connected to it from my Windows box, then told my firewall to block all traffic between the two. Windows, then, immediately reported the error.

This is a bug in Windows. My guess is they (Microsoft) sent a packet and waited a bit for something/anything. A few seconds passed when this semaphore error appeared. Not getting any packets back, at all, for a few seconds is typical networking on the Internet and Microsoft's Windows is not waiting anywhere near long enough.

So, I'm tempted to open a GitHub Issue for Windows that we need to specifically check for this error and ignore it.

ETA: Ignoring the Windows error would simply make Windows work like Linux and (probably) macOS. That is, you're still disconnected and you still can't open a new game until you log in again. But it should come up with a more appropriate error message (connection time out or some such) as it currently does on Linux. You'll still be left with the issue that your local network and/or ISP are improperly dropping the connection.
I forked real life and now I'm getting merge conflicts.
Ado64
Posts: 18
Joined: August 5th, 2018, 2:29 pm

Re: Connection failed: the semaphore timeout has expired

Post by Ado64 »

Tad_Carlucci wrote: January 27th, 2019, 7:48 pm ISP are improperly dropping the connection.
Hi Tad, as actually there's some ISP that use its internal nat for commercial purposes (and in my opinion they will be more in the next few years), what about implementing something like that?
Pentarctagon wrote: January 25th, 2019, 6:00 pm Perhaps something that could be enabled in Advanced Preferences to automatically do /q (or something that accomplishes the same), for example.
If it's not a big effort it would help many people without impacting who doesn't need it.

Thanks
Tad_Carlucci
Inactive Developer
Posts: 503
Joined: April 24th, 2016, 4:18 pm

Re: Connection failed: the semaphore timeout has expired

Post by Tad_Carlucci »

As to the use of NAT: The only reason for a reasonably competent ISP to use NAT these days is to proxy legacy IPv4 addresses to IPv6 for their customers who cannot or will not upgrade. But, since that includes a LOT of cellular telephones and Internet-connected hardware like cameras, televisions, and light bulbs, I expect you'll see a bit of that. Here, in my house, for instance, the moment IPv6 becomes available (no idea why it's not other than simple laziness from the cable company) I'll have to maintain the IPv4 NAT WiFi network, myself, but will certainly jump most of my computers to a static IPv6 address block.

Adding an option to the client preferences will help, but not solve the issue. Fixing the Windows client to die more gracefully, like Linux does, would also help. But a badly set up network is a badly set up network, and nothing we can do will fix that. As was stated above, the /q pinging has already been shown to not work around the issue in some cases.
I forked real life and now I'm getting merge conflicts.
Tad_Carlucci
Inactive Developer
Posts: 503
Joined: April 24th, 2016, 4:18 pm

Re: Connection failed: the semaphore timeout has expired

Post by Tad_Carlucci »

---

That's too harsh. It's probably not a badly set up network. It's probably an error. It might be in the in-house router, or it might be someplace in the ISP's network.

Personally, if I had this issue on my network, I'd swap in my backup router to ensure it's not my problem, tether a laptop to test using cellular data, and then, when I was confident it was not my problem, I'd have my ISP's technician out to either fix the randomly- (and silently-) dropped connection or give me a darned good reason for them doing it (and demand a contact to file a complaint with about their bad choices).
I forked real life and now I'm getting merge conflicts.
Ado64
Posts: 18
Joined: August 5th, 2018, 2:29 pm

Re: Connection failed: the semaphore timeout has expired

Post by Ado64 »

Tad_Carlucci wrote: January 28th, 2019, 9:36 pm As was stated above, the /q pinging has already been shown to not work around the issue in some cases.
OK I don't want to insist more, if this is your choice I'll accept it. But just to clarify, the /q workaround has never failed, if you are referring to this:
Yomar wrote: January 27th, 2019, 2:13 pm I just played and was disconnected even with the automated messages, bot.
But now it happens much lesser.
Still I got the message, like four or five times today.
It was another workaround (the ravana's bot that pings a user every x minutes) and it's not working for me neither. But /q workaround (if you send /q before your connection has already been disconnected of course, as I told to Yomar some post above) works wonderfully!

I just want to add back that I already tethered my laptop with my mobile connection (another isp than the home one) and I had the same problem, I also changed laptop (no antivirus, no firewall, absolutely nothing) and the issue has always been there... I can only imagine how many other users in the world that don't write on a (english) forum could have experienced the same issue...

Good Game
Tad_Carlucci
Inactive Developer
Posts: 503
Joined: April 24th, 2016, 4:18 pm

Re: Connection failed: the semaphore timeout has expired

Post by Tad_Carlucci »

To summarize:

1) Ravana's robot is an acceptable hack for a quick-and-dirty workaround. The issue is probably the frequency. My experience is you can shorten the delay, increasing bandwidth use, and decreasing the number of complaints. But you will always have some remaining users still experiencing the issue. So it's a question of what works "well enough". Ravana might want to lower the minimum to 15 or 30 seconds, if possible, for a broader net catching more users.

2) The Windows client should be changed to ignore the semaphore error and die more gracefully, like the Linux and macOS clients do when faced with the exact same issue. For this, unplugging a cable or blocking all traffic at the firewall will simulate the issue sufficiently for testing. This, in itself, should reduce the number of complaints since what the user sees will be more consistent and less cryptic.

3) The issue is that Windows has some internal timer which is set far too short to handle a total loss of packets. (I note this error seems fairly common on Windows, most often reported on SQL transactions and backup runs.) There are reasons the TCP suggests times like five or ten minutes for such timers. Someone who knows the Windows networking API might be able to correct this timeout to something more reasonable, like 15 minutes, before walking away from the conversation. It occurs to me that simply ignoring the Windows error might do just that. It's been decades since I've done any serious Windows programming, so I just don't know what's possible there.

4) The root issue is that some users (or their ISPs, don't know which) are dropping sufficient packets on their networks that Windows is unhappy. High packet loss is usually a fixable problem. One should take steps to get their packet loss repaired before resorting to Ravana's hack, especially considering that it may be some time before the Windows client change appear (assuming they are possible and have any effect at all).

I have created an Issue to memorialize this conversation.
I forked real life and now I'm getting merge conflicts.
Soliton
Site Administrator
Posts: 1680
Joined: April 5th, 2005, 3:25 pm
Location: #wesnoth-mp

Re: Connection failed: the semaphore timeout has expired

Post by Soliton »

The server has enabled a keep alive feature that sends packets if the connection is idle. We've now lowered the timeout from 2 hours to 30 seconds. The 1.14 server has already been restarted. Please report if that helps without the bot workaround.
"If gameplay requires it, they can be made to live on Venus." -- scott
gnombat
Posts: 682
Joined: June 10th, 2010, 8:49 pm

Re: Connection failed: the semaphore timeout has expired

Post by gnombat »

I tested this with my network by logging in to the official server, creating a game and waiting 15 minutes, and returning to the lobby; I no longer see the error message and I'm obviously still connected, so it appears to be working. (I can still force the error message to appear by manually blocking port 14999 via firewall as suggested previously.)
Ado64
Posts: 18
Joined: August 5th, 2018, 2:29 pm

Re: Connection failed: the semaphore timeout has expired

Post by Ado64 »

Soliton wrote: January 30th, 2019, 12:55 pm The server has enabled a keep alive feature that sends packets if the connection is idle. We've now lowered the timeout from 2 hours to 30 seconds. The 1.14 server has already been restarted. Please report if that helps without the bot workaround.
It's working! thanks very much :eng:
Tad_Carlucci
Inactive Developer
Posts: 503
Joined: April 24th, 2016, 4:18 pm

Re: Connection failed: the semaphore timeout has expired

Post by Tad_Carlucci »

Marking the Githib Issue closed, then.
I forked real life and now I'm getting merge conflicts.
bismitch
Posts: 24
Joined: August 12th, 2005, 8:38 pm

Re: Connection failed: the semaphore timeout has expired

Post by bismitch »

I just got this error today and it keeps happening after a long idle time. This is with a recent installation of windows 10 wesnoth. There shouldn't be issues with my home network. Or at least it worked a year ago. It is a different windows installation though.
dancedance
Posts: 1
Joined: May 1st, 2023, 4:23 am

Re: Connection failed: the semaphore timeout has expired

Post by dancedance »

I keep getting this error with every MP game I play all of a sudden. I've made no changes or updates to my system, and wasn't having this issue before. Now, about every 5 minutes I get a semaphore error message, and get booted from the game and attempting to reconnect tells me my account is still logged into the server. I don't have this problem with any other game or program. In fact, I've never had this issue before until playing this game. I've read through all the existing posts about this issue here and tried some of the suggestions but none of them did anything. So, what's the deal, Wesnoth?
User avatar
Pentarctagon
Project Manager
Posts: 5531
Joined: March 22nd, 2009, 10:50 pm
Location: Earth (occasionally)

Re: Connection failed: the semaphore timeout has expired

Post by Pentarctagon »

Can you provide the relevant information listed in viewtopic.php?t=25660 ?
99 little bugs in the code, 99 little bugs
take one down, patch it around
-2,147,483,648 little bugs in the code
Post Reply