The International Simutrans Forum

 

Author Topic: Better info of connecting to server and handling of disconnects  (Read 3138 times)

0 Members and 1 Guest are viewing this topic.

Offline ӔO

  • Devotees (Inactive)
  • *
  • Posts: 2345
  • Hopefully helpful
  • Languages: en, jp
While connecting to a server, there is only a bar representation of how much progress has been made to connect.
And if your internet disconnects while transferring, the game will wait forever in the loading screen.

Could there be a numerical representation of how much of the save game is transferred? I prefer (transferred KB/total KB)

Could the game potentially detect when there is no more connection and cancel the transfer? Currently, you have to close it, because the program becomes unresponsive.

Offline Ters

  • Coder/patcher
  • Devotee
  • *
  • Posts: 5543
  • Languages: EN, NO
Re: Better info of connecting to server and handling of disconnects
« Reply #1 on: May 01, 2014, 08:24:10 AM »
Sounds like a familiar problem from work. If the connection breaks under the right circumstances (I think it is when waiting to receive data), there is no way of knowing that it has broken, as opposed to the sending side just taking a long time to send the data or some congestion along the way (or as far as the underlying protocol is concerned, there simply isn't supposed to be transmitted any data). Simutrans is however down on the socket API and can choose to set timeouts and assume that the connection is dead if they fail. The big question is what that timeout should be to avoid dropping connections that is just temporarily a bit slow.

Online prissi

  • Developer
  • Administrator
  • *
  • Posts: 9569
  • Languages: De,EN,JP
Re: Better info of connecting to server and handling of disconnects
« Reply #2 on: May 01, 2014, 08:34:08 AM »
Simutrans relies on Windows Posix subsystem. Go, blame them (and the libary makers). Timeout in Windows during my test were (depending on version and libary version) something between 30s and >10 min. It never was that badly under Linux for me, although I did not do many tests there.

We ask the routine for a 10s timeout. If the routine has some data, we ask it for all the data it got. But sometimes the routine says it has data but then does not and hangs. That is all we can do.




Offline Ters

  • Coder/patcher
  • Devotee
  • *
  • Posts: 5543
  • Languages: EN, NO
Re: Better info of connecting to server and handling of disconnects
« Reply #3 on: May 01, 2014, 09:12:43 AM »
At work, we've had systems hanging for days. As far as I have been able to figure out, TCP has no heartbeat by default. But there appears to be a SO_KEEPALIVE option one can turn on, but I have never tried using it. It seems that the default time-out is two hours on both Windows and Linux, but this in configurable for both. At this point, it begins sending keepalive packets relatively often (configurable, but appearently with different defaults). If a certain number of keepalive packets are sent without a response, the connection is considered dead. I assume this means recv will return with an error.

Online prissi

  • Developer
  • Administrator
  • *
  • Posts: 9569
  • Languages: De,EN,JP
Re: Better info of connecting to server and handling of disconnects
« Reply #4 on: May 01, 2014, 12:45:12 PM »
OK, I added some code with adds 10s timeouts to file transfers.

Offline TurfIt

  • Dev Team, Coder/patcher
  • Devotee
  • *
  • Posts: 1326
Re: Better info of connecting to server and handling of disconnects
« Reply #5 on: May 01, 2014, 11:00:13 PM »
Could there be a numerical representation of how much of the save game is transferred? I prefer (transferred KB/total KB)
That's the information conveyed by the bar, although it was broken. Assuming it's working, are the numbers needed too?

Offline Sarlock

  • Devotee
  • *
  • Posts: 1340
  • Languages: EN
Re: Better info of connecting to server and handling of disconnects
« Reply #6 on: May 02, 2014, 12:49:13 AM »
If the bar is properly filling, I think that would work fine, at least then you'd know where you're at with the download (and how long you have to get a cup of coffee before it's done...).

Offline AP

  • Devotee
  • *
  • Posts: 1202
  • Languages: EN
Re: Better info of connecting to server and handling of disconnects
« Reply #7 on: May 02, 2014, 05:23:05 AM »
Another related issue - when gameplay is in progress and the server connection is lost, the player can carry on playing - there is no pup-up or other prominent indication that something is wrong, which I suggest needs addressing. The only clue is the absence of a little tiny icon in the corner. I've wasted a good few hours this way.

Offline Sarlock

  • Devotee
  • *
  • Posts: 1340
  • Languages: EN
Re: Better info of connecting to server and handling of disconnects
« Reply #8 on: May 02, 2014, 02:21:36 PM »
Interesting.  I always get the Simutrans main menu come up when I lose connection (the one that allows you to start a new game/load, etc).  I wonder what is different between us that doesn't give you that.

Offline Sarlock

  • Devotee
  • *
  • Posts: 1340
  • Languages: EN
Re: Better info of connecting to server and handling of disconnects
« Reply #9 on: May 02, 2014, 08:48:26 PM »
FYI, if you're interested in seeing how much progress you've made in downloading the server game, just check in your Simutrans user folder (on Windows) and watch the file "clientx-network.sve" grow in size by refreshing.  Current server game is around 45MB.

Offline ӔO

  • Devotees (Inactive)
  • *
  • Posts: 2345
  • Hopefully helpful
  • Languages: en, jp
Re: Better info of connecting to server and handling of disconnects
« Reply #10 on: May 02, 2014, 11:28:25 PM »
That's the information conveyed by the bar, although it was broken. Assuming it's working, are the numbers needed too?

For me, the download completes at about 70% of the bar, then it goes into the loading/creating map bar for about 1~2 seconds

Online prissi

  • Developer
  • Administrator
  • *
  • Posts: 9569
  • Languages: De,EN,JP
Re: Better info of connecting to server and handling of disconnects
« Reply #11 on: May 03, 2014, 01:24:39 PM »
The bar is updated in 4kB intervalls. If the game is small enough, then it will end a little bit before.