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:
User avatar
josteph
Inactive Developer
Posts: 741
Joined: August 19th, 2017, 6:58 pm

Re: Connection failed: the semaphore timeout has expired

Post by josteph »

Even if we set it to a not very small value so it fixes the problem only for some clients, that'd still be valuable. I suggested it because it's something we can implement without waiting for 1.14.6.
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 »

The problem with using SO_KEEPALIVE is the "client" referred to earlier is the computer on which the TCP socket option is set. The values (time, interval and probes) are system-wide.

So, yes, we could set SO_KEEPALIVE on the server (wesnothd) and we could even adjust the parameters to be unreasonably small on the BfW official MP server. Even if this works for the OP, it seems a fragile and wasteful fix. (Do we really need, or even want, to send keepalives out EVERY player's connection every second or two because ONE player's network has problems with the default 60-second interval?)

My feeling is that the OP's router/modem is doing NAT and has a very short NAT keepalive value. This is one of the reasons I suggested testing on other networks. Depending on the router, the NAT timeout might be tuned to make allowance for excessive latency communicating with the MP server.

Finally, if this really is an error message from Wesnoth, someone needs to find it and replace it with something more reasonable. Sure a semaphore timed out. But if the error means that the connection to the MP server has timed out, it would probably be better to just say that.
I forked real life and now I'm getting merge conflicts.
gnombat
Posts: 682
Joined: June 10th, 2010, 8:49 pm

Re: Connection failed: the semaphore timeout has expired

Post by gnombat »

Tad_Carlucci wrote: January 5th, 2019, 8:05 am My feeling is that the OP's router/modem is doing NAT and has a very short NAT keepalive value. This is one of the reasons I suggested testing on other networks. Depending on the router, the NAT timeout might be tuned to make allowance for excessive latency communicating with the MP server.
But I don't really think that 10 minutes is "very short" - I suspect it's fairly common these days. My network has a timeout which is shorter than that (5 minutes). (Personally, I'm using a consumer-level network connection and hardware provided by a large ISP which likely has millions of users.)

Possibly the timeout can be changed by modifying router settings, but that doesn't seem like the ideal solution to me:
  1. It might not be possible to change the settings
  2. It's not a very user-friendly solution
  3. It may be overkill to change the router's global settings for all connections when all you want to do is allow a single program (Wesnoth) to be able to maintain its connection to the server
I suspect that the best solution would be to do something similar to what OpenSSH does - it has a setting ServerAliveInterval which clients can set to prevent connections from being idle for too long.

https://www.howtogeek.com/howto/linux/k ... onnecting/

While this is not a perfect solution (it requires users to manually set the setting to a value which will work for their network), it allows users to fix the issue without having to change their network's configuration.
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 »

I agree tweaking the router is sub-optimal and a client-software option would be better.

But I'm still thinking we're running off fixing something which may not even be the core issue.

We might be spending a lot of time 'fixing' an error which is actually something else like an equipment failure at the OP's ISP.
I forked real life and now I'm getting merge conflicts.
gnombat
Posts: 682
Joined: June 10th, 2010, 8:49 pm

Re: Connection failed: the semaphore timeout has expired

Post by gnombat »

I can't speak for the OP, but when testing it on my own network, it certainly looks like idle connections are the crux of the issue.

For example, if I create a game, then manually prevent a connection from being idle for too long by typing /q every few minutes, then the error does not seem to occur.

It appears that the connection can be maintained indefinitely without errors by periodically typing the "/q" command
It appears that the connection can be maintained indefinitely without errors by periodically typing the "/q" command

But if I try to create a game and then leave the connection idle for more than 5 minutes, then when I cancel the game I get the error:

connection-failed.png
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 »

Assuming this is similar to the OP's issue, the question is: what is it about his network which causes this for him, when nobody else sees (or, at least, reports) the error in normal operations.

If, for instance, there is something about his network which allows him to start a game but, then, completely blocks all traffic to the established game, then no amount of keepalive messages (such as your /q invalid commands) will solve his problem. This could be something as simple as a misconfigured firewall. We don't know because the OP has given virtually NO information: just the text of error message, and that it's on two of his Windows boxes.
I forked real life and now I'm getting merge conflicts.
gnombat
Posts: 682
Joined: June 10th, 2010, 8:49 pm

Re: Connection failed: the semaphore timeout has expired

Post by gnombat »

Tad_Carlucci wrote: January 6th, 2019, 12:09 am Assuming this is similar to the OP's issue, the question is: what is it about his network which causes this for him, when nobody else sees (or, at least, reports) the error in normal operations.
How do we know that nobody else sees or reports this? There was a post above that shows several bugs in the bug tracker which could be related to this:
https://github.com/wesnoth/wesnoth/issues/1336 wrote:...In general, it feels like Wesnoth client is disconnected far too often...
https://github.com/wesnoth/wesnoth/issues/1520 wrote:...It happens that a player is no more in game while others are waiting for his move (i.e.network disconnection...
These reports are too vague to tell exactly what is going on, but they could be seeing the same issue.
Tad_Carlucci wrote: January 6th, 2019, 12:09 am If, for instance, there is something about his network which allows him to start a game but, then, completely blocks all traffic to the established game, then no amount of keepalive messages (such as your /q invalid commands) will solve his problem. This could be something as simple as a misconfigured firewall. We don't know because the OP has given virtually NO information: just the text of error message, and that it's on two of his Windows boxes.
We also know two conditions under which the issue was observed:
  1. After creating a new game and waiting for somebody to join for ten minutes
  2. While playing a multiplayer scenario and nobody makes a move for about ten minutes
Those two situations appear to me to be similar in that they are both cases where the connection seems likely to be idle, although I don't know enough about Wesnoth's network protocol to be sure about that.

In those two situations - is there any network traffic occurring between the client and the server?
Ado64
Posts: 18
Joined: August 5th, 2018, 2:29 pm

Re: Connection failed: the semaphore timeout has expired

Post by Ado64 »

gnombat wrote: January 4th, 2019, 4:55 pm I was able to reproduce this on my machine/network: I created a game on the multiplayer server, waited 5 minutes, then cancelled the game, then when I tried creating another game I got the message "Connection failed: The semaphore timeout period has expired".

(Note: I chose 5 minutes because I happen to know that is the timeout for idle connections on my network.)
Great! I saw your screenshot and this is exactly the issue I've caught! I've to try the /q work around, it would be a good solution, but is there a way to definitely increase the idle connections timeout of my network? I had a look on my modem/router configuration but I didn't find any setting to do this.

Just to give you some more info: I don't have my own nat at home, but I use the most common ISP in Italy: "Telecom Italia" and they have their Nat to maximize number of connections, of course it's not under my control. It means that I don't have a static ip address (like almost all other people here) but a dynamic one. To take a static ip address I should pay much more money and, at least here in Italy, nobody does that for home connections.

I also shutdown all my local firewalls and forwarded port 15000 on my router (though it shouldn't have any effect as I don't get connected to the wesnoth server using the IP address of my own LAN of course)

Thanks in advance
User avatar
Yomar
Posts: 394
Joined: October 27th, 2011, 5:14 am
Contact:

Re: Connection failed: the semaphore timeout has expired

Post by Yomar »

Yeah, happened to me too during game.
Beholded Wesnoth's Origins.
Max G on WIF
Rank 🌟🌟🌟🌟🌟
Ado64
Posts: 18
Joined: August 5th, 2018, 2:29 pm

Re: Connection failed: the semaphore timeout has expired

Post by Ado64 »

FYI: I was able to work around this issue by manually sending /q every few minutes. It would be great if it will be fixed definitively, but right now I'm able atleast to play... :)

Thanks
User avatar
Yomar
Posts: 394
Joined: October 27th, 2011, 5:14 am
Contact:

Re: Connection failed: the semaphore timeout has expired

Post by Yomar »

I'm very disappointed, I get the "Connection failed: The semaphore timeout period has expired", problem so often, that I can not play anymore.
I'm annoyed that I have to reload a game like 3 or 4 times for one match.
And my play mates get irritated too.
I tried to disable the firewall, but for no avail.
I can't play, I cant watch matches, wait for players to join, and not even stick around in the lobby, with this pesky bug around.
The thing, is that it never happened before.
Beholded Wesnoth's Origins.
Max G on WIF
Rank 🌟🌟🌟🌟🌟
User avatar
Pentarctagon
Project Manager
Posts: 5526
Joined: March 22nd, 2009, 10:50 pm
Location: Earth (occasionally)

Re: Connection failed: the semaphore timeout has expired

Post by Pentarctagon »

When did it start happening?
99 little bugs in the code, 99 little bugs
take one down, patch it around
-2,147,483,648 little bugs in the code
Ado64
Posts: 18
Joined: August 5th, 2018, 2:29 pm

Re: Connection failed: the semaphore timeout has expired

Post by Ado64 »

Yomar wrote: January 23rd, 2019, 7:42 pm The thing, is that it never happened before.
Did you change your Internet service provider recently? As far as I understood the problem is that many isp (like mine) uses a Nat to maximize number of ip addresses they can sell, but with a natted client the bfw server is unable to detect it and close its connection after few minutes.

Even if you haven't changed your provider recently, they could have changed their infrastructure in the while and this could be the reason why you get this error just right now.

To survive you can manually send /q every few minutes and your connection will be kept alive.

Regards
Last edited by Ado64 on January 24th, 2019, 11:10 am, edited 2 times in total.
User avatar
Ravana
Forum Moderator
Posts: 2949
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: Connection failed: the semaphore timeout has expired

Post by Ravana »

I can leave my bot online so that you could message it in order for it to keep sending you message every few minutes. If there is interest, I will set it up in the evening.
Ado64
Posts: 18
Joined: August 5th, 2018, 2:29 pm

Re: Connection failed: the semaphore timeout has expired

Post by Ado64 »

Ravana wrote: January 24th, 2019, 10:33 am I can leave my bot online so that you could message it in order for it to keep sending you message every few minutes. If there is interest, I will set it up in the evening.
Thanks ravana but as I said there is already a workaround for this (sending /q). Now the best thing to do would be to make a server-side fix in order to manage the "keep alive" mechanism in a different way.

Thanks
Post Reply