[0.14.22] Arch server connect/reconnect troubles

This subforum contains all the issues which we already resolved.
Post Reply
quyxkh
Smart Inserter
Smart Inserter
Posts: 1028
Joined: Sun May 08, 2016 9:01 am
Contact:

[0.14.22] Arch server connect/reconnect troubles

Post by quyxkh »

Connecting via lan (loopback, 127.0.0.1) with this straightforward server setup hangs with an unresponsive server and the logs shown here:

Code: Select all

(ins)~/steam/Factorio$ type doit
doit is a function
doit () 
{ 
    cd ~/steam/Factorio;
    rm -rf ~/.factorio/saves/MP;
    mkdir ~/.factorio/saves/MP;
    diff -u0 data/server-settings.example.json ~/.factorio/server-settings.json;
    bin/x64/factorio --create ~/.factorio/saves/MP/1.zip;
    bin/x64/factorio --start-server ~/.factorio/saves/MP/1.zip
}
(ins)~/steam/Factorio$ -x doit
+ doit
+ cd /home/quyxkh/steam/Factorio
+ rm -rf /home/quyxkh/.factorio/saves/MP
+ mkdir /home/quyxkh/.factorio/saves/MP
+ diff -u0 data/server-settings.example.json /home/quyxkh/.factorio/server-settings.json
--- data/server-settings.example.json   2016-11-03 07:49:03.882241547 -0700
+++ /home/quyxkh/.factorio/server-settings.json 2017-04-04 12:58:32.617337182 -0700
@@ -13 +13 @@
-    "public": true,
+    "public": false,
@@ -18 +18 @@
-  "username": "",
+  "username": "quyxkh",
@@ -22 +22 @@
-  "token": "",
+  "token": "hunter2",
@@ -33 +33 @@
-  "minimum_latency_in_ticks": 0,
+  "minimum_latency_in_ticks": 3,
@@ -59 +59 @@
-  "admins": []
+  "admins": ["quyxkh"]
+ bin/x64/factorio --create /home/quyxkh/.factorio/saves/MP/1.zip
   0.000 2017-04-04 13:12:57; Factorio 0.14.22 (build 25342, linux64, steam)
   0.012 Operating system: Linux (Arch rolling)
   0.012 Program arguments: "bin/x64/factorio" "--create" "/home/quyxkh/.factorio/saves/MP/1.zip" 
   0.012 Read data path: /home/quyxkh/steamapps/steamapps/common/Factorio/data
   0.012 Write data path: /home/quyxkh/.factorio
   0.012 Binaries path: /home/quyxkh/steamapps/steamapps/common/Factorio/bin
   0.024 System info: [CPU:        Intel(R) Core(TM) i5-3570K CPU @ 3.40GHz, 4 cores, RAM: 16035MB]
   0.025 Running in headless mode
   0.034 Loading mod core 0.0.0 (data.lua)
   0.038 Loading mod base 0.14.22 (data.lua)
   0.121 Checksum for core: 1291735968
   0.121 Checksum for mod base: 786624017
   0.402 Info PlayerData.cpp:55: Local player-data.json available, timestamp 1491335650
   0.402 Info PlayerData.cpp:62: Cloud player-data.json unavailable
   0.404 Custom inputs active: 0
   0.404 Factorio initialised
   0.404 Info Main.cpp:613: Creating new map /home/quyxkh/.factorio/saves/MP/1.zip
   2.923 Error FileUtil.cpp:284: Can't remove /home/quyxkh/.factorio/temp/currently-playing: No such file or directory
   2.961 Info Scenario.cpp:152: Map version 0.14.22-0
   2.997 Checksum for script /home/quyxkh/.factorio/temp/currently-playing/control.lua: 1057114497
Done.
+ bin/x64/factorio --start-server /home/quyxkh/.factorio/saves/MP/1.zip
   0.000 2017-04-04 13:13:00; Factorio 0.14.22 (build 25342, linux64, steam)
   0.011 Operating system: Linux (Arch rolling)
   0.011 Program arguments: "bin/x64/factorio" "--start-server" "/home/quyxkh/.factorio/saves/MP/1.zip" 
   0.011 Read data path: /home/quyxkh/steamapps/steamapps/common/Factorio/data
   0.011 Write data path: /home/quyxkh/.factorio
   0.011 Binaries path: /home/quyxkh/steamapps/steamapps/common/Factorio/bin
   0.022 System info: [CPU:        Intel(R) Core(TM) i5-3570K CPU @ 3.40GHz, 4 cores, RAM: 16035MB]
   0.023 Running in headless mode
   0.030 Loading mod core 0.0.0 (data.lua)
   0.034 Loading mod base 0.14.22 (data.lua)
   0.114 Checksum for core: 1291735968


   0.114 Checksum for mod base: 786624017
   0.392 Info PlayerData.cpp:55: Local player-data.json available, timestamp 1491335650
   0.392 Info PlayerData.cpp:62: Cloud player-data.json unavailable
   0.393 Custom inputs active: 0
   0.394 Factorio initialised
   0.394 Info ServerSynchronizer.cpp:27: nextHeartbeatSequenceNumber(0) initialized Synchronizer nextTickClosureTick(0).
   0.394 Info ServerMultiplayerManager.cpp:658: mapTick(-1) changing state from(Ready) to(PreparedToHostGame)
   0.394 Info ServerMultiplayerManager.cpp:658: mapTick(-1) changing state from(PreparedToHostGame) to(CreatingGame)
   0.395 Loading map /home/quyxkh/.factorio/saves/MP/1.zip
   0.395 Error FileUtil.cpp:284: Can't remove /home/quyxkh/.factorio/temp/currently-playing: No such file or directory
   0.406 Info Scenario.cpp:152: Map version 0.14.22-0
   0.431 Checksum for script /home/quyxkh/.factorio/temp/currently-playing/control.lua: 1057114497
   0.432 Info UDPSocket.cpp:27: Opening socket at (0.0.0.0:34197)
   0.432 Hosting game at 0.0.0.0:34197
   0.432 Info HttpSharedState.cpp:44: Downloading https://auth.factorio.com/generate-server-padlock
   1.129 Info HttpSharedState.cpp:111: Status code: 200
   1.129 Info AuthServerConnector.cpp:106: Obtained serverPadlock for serverHash (qqz5NYPhMZWqm9qBkGNuzyPhqfs92bl4) from the auth server.
   1.129 Info ServerMultiplayerManager.cpp:658: mapTick(0) changing state from(CreatingGame) to(InGame)
   1.129 Info UDPSocket.cpp:39: Opening socket for broadcast
  33.965 ConnectionRequestReplyConfirm (type(ConnectionRequestReplyConfirm) ) from(192.168.1.2:41192)
  33.965 Refusing connection for address(192.168.1.2:41192). User verification is required for this game.
  34.485 ConnectionRequestReplyConfirm (type(ConnectionRequestReplyConfirm) ) from(192.168.1.2:46679)
  34.485 Info ServerRouter.cpp:413: Replying to connectionRequest for address(192.168.1.2:46679).
  34.485 Info ServerSynchronizer.cpp:524: nextHeartbeatSequenceNumber(995) adding peer(1)
  34.502 Info ServerMultiplayerManager.cpp:658: mapTick(0) changing state from(InGame) to(InGameSavingMap)
  34.502 Warning WriteFileGuard.cpp:25: Writing /home/quyxkh/.factorio/temp/mp-save-0.zip failed; previous version (if any) should still be available
  34.502 Error ParallelScenarioSaver.cpp:82: Saving scenario failed: Error when opening /home/quyxkh/.factorio/temp/currently-playing/replay.dat for reading: No such file or directory
  34.518 Info ServerMultiplayerManager.cpp:742: mapTick(0) received stateChang

ed peerID(1) oldState(Ready) newState(ConnectedWaitingForMap)
  34.519 Error ServerMultiplayerManager.cpp:93: MultiplayerManager failed: multiplayer.cannot-save-map("Error when opening /home/quyxkh/.factorio/temp/currently-playing/replay.dat for reading: No such file or directory")
  34.519 Info ServerMultiplayerManager.cpp:658: mapTick(0) changing state from(InGameSavingMap) to(Failed)
^C  62.933 Received SIGINT, shutting down
  62.933 Info MainLoop.cpp:219: Saving map as /home/quyxkh/.factorio/saves/MP/1.zip
  62.934 Warning WriteFileGuard.cpp:25: Writing /home/quyxkh/.factorio/saves/MP/1.zip failed; previous version (if any) should still be available
  62.934 Error Util.cpp:57: Error when opening /home/quyxkh/.factorio/temp/currently-playing/replay.dat for reading: No such file or directory
  63.017 Error FileUtil.cpp:284: Can't remove /home/quyxkh/.factorio/temp/currently-playing: No such file or directory
  63.019 Info ServerMultiplayerManager.cpp:139: Quitting multiplayer connection.
  63.019 Info ServerMultiplayerManager.cpp:658: mapTick(-1) changing state from(Failed) to(Closed)
terminate called after throwing an instance of 'std::system_error'
  what():  Invalid argument
  63.551 Warning Logger.cpp:369: Symbols.size() == 25, usedSize == 24
Factorio crashed. Generating symbolized stacktrace, please wait ...
  64.080 Warning Logger.cpp:369: Symbols.size() == 24, usedSize == 23
#0  0x00000000005c71bb in CrashHandler::writeStackTrace() at /tmp/factorio-X5N2Rm/src/Util/CrashHandler.cpp:105
#1  0x00000000005c7454 in CrashHandler::SignalHandler(int) at /tmp/factorio-X5N2Rm/src/Util/CrashHandler.cpp:235
#2  0x00007f2306c72a90 in ?? at ??:0
#3  0x00007f2306c72a10 in ?? at ??:0
#4  0x00007f2306c7413a in ?? at ??:0
#5  0x000000000117737d in __gnu_cxx::__verbose_terminate_handler() at ??:?
#6  0x000000000116bb26 in __cxxabiv1::__terminate(void (*)()) at ??:?
#7  0x00000000011ce979 in __cxa_call_terminate at ??:?
#8  0x000000000116ccf5 in __gxx_personality_v0 at ??:?
#9  0x00007f2306ff2f43 in ?? at ??:0
#10 0x00007f2306ff32ab in ?? at ??:0
#11 0x0000000001176fcb in __cxa_throw at ??:?
#12 0x00000000011a031f in std::__throw_system_error(int) at ??:?
#13 0x00000000007984bd in TaskManager::removeTask(Task*) at /usr/include/c++/5/mutex:139
#14 0x00000000007985cf in ServerGameUpdater::setLANGame(bool) at /tmp/factorio-X5N2Rm/src/Net/ServerGameUpdater.cpp:55
#15 0x0000000000b87681 in ServerMultiplayerManager::destroy() at /tmp/factorio-X5N2Rm/src/Net/ServerMultiplayerManager.cpp:172
#16 0x0000000000a1fbb6 in ServerMultiplayerManager::quit() at /tmp/factorio-X5N2Rm/src/Net/ServerMultiplayerManager.cpp:147
#17 0x0000000000a26fd5 in ServerMultiplayerManager::~ServerMultiplayerManager() at /tmp/factorio-X5N2Rm/src/Net/ServerMultiplayerManager.cpp:69
#18 0x0000000000a27129 in ServerMultiplayerManager::~ServerMultiplayerManager() at /tmp/factorio-X5N2Rm/src/Net/ServerMultiplayerManager.cpp:77
#19 0x0000000000b8927b in clearResources at /tmp/factorio-X5N2Rm/src/GlobalContext.cpp:526
#20 0x0000000000cfa1d8 in GlobalContext::~GlobalContext() at /tmp/factorio-X5N2Rm/src/GlobalContext.cpp:574
#21 0x00007f2306c5f511 in main at /tmp/factorio-X5N2Rm/src/Main.cpp:532 (discriminator 1)
#22 0x000000000040b1a9 in ?? at ??:0
  64.080 Error Util.cpp:77: Unexpected error occurred. If you're running the latest version of the game you can help us solve the problem by posting the contents of the log file on the Factorio forums.
Please also include the save file(s), any mods you may be using, and any steps you know of to reproduce the crash.
+ set +xv
(ins)~/steam/Factorio$ 
This version works for a single connection:

Code: Select all

doit () 
{ 
    cd ~/steam/Factorio;
    rm -rf ~/.factorio/saves/MP;
    mkdir ~/.factorio/saves/MP;
    sed -si '/auto_pause/s/true/false/' ~/.factorio/server-settings.json;
    diff -u0 data/server-settings.example.json ~/.factorio/server-settings.json;
    bin/x64/factorio --create ~/.factorio/saves/MP/1.zip;
    bin/x64/factorio --start-server ~/.factorio/saves/MP/1.zip  <<EOD
/save
/quit
EOD
    sed -si '/auto_pause/s/false/true/' ~/.factorio/server-settings.json;
    bin/x64/factorio --start-server ~/.factorio/saves/MP/1.zip
}

addendum: but _re_connecting doesn't work, it hangs with the same replay.dat error. I have to quit and restart the server to reconnect .. which loses progress, the logs from trying a /save:

Code: Select all

/save
 332.976 Info AppManager.cpp:237: Saving game as /home/quyxkh/.factorio/saves/MP/1.zip
Saving map to /home/quyxkh/.factorio/saves/MP/1.zip
 332.976 Warning WriteFileGuard.cpp:25: Writing /home/quyxkh/.factorio/saves/MP/1.zip failed; previous version (if any) should still be available
 332.977 Error ParallelScenarioSaver.cpp:82: Saving scenario failed: Error when opening /home/quyxkh/.factorio/temp/currently-playing/replay.dat for reading: No such file or directory
 332.993 Error Util.cpp:57: Attempting to create notice box in headless mode. Message: 'Error when opening /home/quyxkh/.factorio/temp/currently-playing/replay.dat for reading: No such file or directory'
 333.202 Info ServerMultiplayerManager.cpp:115: Disconnecting multiplayer connection.
 333.202 Info ServerMultiplayerManager.cpp:658: mapTick(18920) changing state from(InGame) to(DisconnectingScheduled)
 333.202 Error FileUtil.cpp:284: Can't remove /home/quyxkh/.factorio/temp/currently-playing: No such file or directory
 333.207 Info ServerMultiplayerManager.cpp:139: Quitting multiplayer connection.
 333.207 Info ServerMultiplayerManager.cpp:658: mapTick(-1) changing state from(DisconnectingScheduled) to(Closed)
terminate called after throwing an instance of 'std::system_error'
  what():  Invalid argument
 333.754 Warning Logger.cpp:369: Symbols.size() == 25, usedSize == 24
Factorio crashed. Generating symbolized stacktrace, please wait ...
 334.273 Warning Logger.cpp:369: Symbols.size() == 24, usedSize == 23
#0  0x00000000005c71bb in CrashHandler::writeStackTrace() at /tmp/factorio-X5N2Rm/src/Util/CrashHandler.cpp:105
#1  0x00000000005c7454 in CrashHandler::SignalHandler(int) at /tmp/factorio-X5N2Rm/src/Util/CrashHandler.cpp:235
#2  0x00007fe27a7a3a90 in ?? at ??:0
#3  0x00007fe27a7a3a10 in ?? at ??:0
#4  0x00007fe27a7a513a in ?? at ??:0
#5  0x000000000117737d in __gnu_cxx::__verbose_terminate_handler() at ??:?
#6  0x000000000116bb26 in __cxxabiv1::__terminate(void (*)()) at ??:?
#7  0x00000000011ce979 in __cxa_call_terminate at ??:?
#8  0x000000000116ccf5 in __gxx_personality_v0 at ??:?
#9  0x00007fe27ab23f43 in ?? at ??:0
#10 0x00007fe27ab242ab in ?? at ??:0
#11 0x0000000001176fcb in __cxa_throw at ??:?
#12 0x00000000011a031f in std::__throw_system_error(int) at ??:?
#13 0x00000000007984bd in TaskManager::removeTask(Task*) at /usr/include/c++/5/mutex:139
#14 0x00000000007985cf in ServerGameUpdater::setLANGame(bool) at /tmp/factorio-X5N2Rm/src/Net/ServerGameUpdater.cpp:55
#15 0x0000000000b87681 in ServerMultiplayerManager::destroy() at /tmp/factorio-X5N2Rm/src/Net/ServerMultiplayerManager.cpp:172
#16 0x0000000000a1fbb6 in ServerMultiplayerManager::quit() at /tmp/factorio-X5N2Rm/src/Net/ServerMultiplayerManager.cpp:147
#17 0x0000000000a26fd5 in ServerMultiplayerManager::~ServerMultiplayerManager() at /tmp/factorio-X5N2Rm/src/Net/ServerMultiplayerManager.cpp:69
#18 0x0000000000a27129 in ServerMultiplayerManager::~ServerMultiplayerManager() at /tmp/factorio-X5N2Rm/src/Net/ServerMultiplayerManager.cpp:77
#19 0x0000000000b8927b in clearResources at /tmp/factorio-X5N2Rm/src/GlobalContext.cpp:526
#20 0x0000000000cfa1d8 in GlobalContext::~GlobalContext() at /tmp/factorio-X5N2Rm/src/GlobalContext.cpp:574
#21 0x00007fe27a790511 in main at /tmp/factorio-X5N2Rm/src/Main.cpp:532 (discriminator 1)
#22 0x000000000040b1a9 in ?? at ??:0
 334.273 Error Util.cpp:77: Unexpected error occurred. If you're running the latest version of the game you can help us solve the problem by posting the contents of the log file on the Factorio forums.
Please also include the save file(s), any mods you may be using, and any steps you know of to reproduce the crash.
but trying to reconnect later fails with the same errors. I'm happy to provide further logs and such, but this happens so fast and in so many ways I figure just starting from the above shell functions will be easiest.

This happens on every save file I `--create`, just a plain `bin/x64/factorio --create` as above to get started with should reproduce it.

daniel34
Global Moderator
Global Moderator
Posts: 2761
Joined: Thu Dec 25, 2014 7:30 am
Contact:

Re: [0.14.22] Arch server connect/reconnect troubles

Post by daniel34 »

Apparently you know your way around Linux better than I do, but

Code: Select all

  62.934 Warning WriteFileGuard.cpp:25: Writing /home/quyxkh/.factorio/saves/MP/1.zip failed
are you sure the user Factorio runs under (I assume it's your user) has permission to write to that file?

Delete the temp folder in .factorio, then make sure Factorio has access to the whole .factorio folder (chmod 755). If Factorio runs under another user then make sure it has access, you can also try to temporarily chmod it to 777 and see if it makes a difference.
quick links: log file | graphical issues | wiki

quyxkh
Smart Inserter
Smart Inserter
Posts: 1028
Joined: Sun May 08, 2016 9:01 am
Contact:

Re: [0.14.22] Arch server connect/reconnect troubles

Post by quyxkh »

daniel34 wrote:Apparently you know your way around Linux better than I do, but

Code: Select all

  62.934 Warning WriteFileGuard.cpp:25: Writing /home/quyxkh/.factorio/saves/MP/1.zip failed
are you sure the user Factorio runs under (I assume it's your user) has permission to write to that file?

Delete the temp folder in .factorio, then make sure Factorio has access to the whole .factorio folder (chmod 755). If Factorio runs under another user then make sure it has access, you can also try to temporarily chmod it to 777 and see if it makes a difference.
Yeah, I'm sure, and just doublechecked. This isn't a permissions problem, everything in that folder's mine, and writable. The file was actually created immediately beforehand by the `bin/x64/factorio --create ~/.factorio/saves/MP/1.zip` you see in the logs there.

Thanks for checking, the older I get, the bigger a fan of checklists I become.

quyxkh
Smart Inserter
Smart Inserter
Posts: 1028
Joined: Sun May 08, 2016 9:01 am
Contact:

Re: [0.14.22] Arch server connect/reconnect troubles

Post by quyxkh »

Got it: the problem is the server and client can't coexist, you have to make a separate config with a separate `write-data` path.

Code: Select all

    mkdir -p ~/.factorio/server
    cd !$
    cp -a ../config .
    sed -si /write-data/s:=.*:=$PWD: config/config.ini
    mv ../server-settings.json .
Then you can `bin/x64/factorio -c ~/.factorio/server/config/config.ini` to use that one.

Would you consider either putting a sentinel file in the write-data path so this gets diagnosed automatically or (my preference) having headless mode use distinct names in the write-data area so the minimum setup for a local server is just "make a server-settings.json in your .factorio and run bin/x64/factorio --start-server-load-latest"?

What prompted all this was Kane's suggestion of having autosaves run by a separate client that exists just to periodically save on the side, so the main server and real clients never have to wait for that. If there was a headless-client mode that only ran console commands, or if there was a quicksave mode that only saved the replay data and generated the full state only on load, by log replay, that would be super awesome. That autosave hiccup can get annoying, particularly when you're in combat and it eats your clicks.

daniel34
Global Moderator
Global Moderator
Posts: 2761
Joined: Thu Dec 25, 2014 7:30 am
Contact:

Re: [0.14.22] Arch server connect/reconnect troubles

Post by daniel34 »

quyxkh wrote:Got it: the problem is the server and client can't coexist, you have to make a separate config with a separate `write-data` path.
I'm surprised that the second instance even loaded. On Windows you immediately get the message that the log file is already in use by another process, and then Factorio (the second instance) shuts down.
This also explains the writing issues since both processes try to write to the same file at the same time.

On Windows I recommend to have a separate installation for the server (the .zip version), I think the same is applicable to Linux, just extract the game files to a separate directory that is only used as server. If you want to connect both instances you'll need to change the port of one instance, see here.

I'm moving this to Not a bug, although it might be a minor issue. I'm not sure what you mean by sentinel file but I think you mean a pid or lock file. As I mentioned above on WIndows it terminates the second instance, but it doesn't appear to do the same on Linux. Having a pid (Process-ID) file that contains the pid of the currently running Factorio instance would prevent the start of a second instance. This file would have to be placed in the write-data folder and Factorio would only prevent a launch if the pid mentioned in the file is still active.
quyxkh wrote:or if there was a quicksave mode that only saved the replay data and generated the full state only on load, by log replay, that would be super awesome.
If you only had the initial map and replay data the game would have to simulate all the game action again and it would take a lot of time, on 100h+ maps potentially tens of hours.
quick links: log file | graphical issues | wiki

Oxyd
Former Staff
Former Staff
Posts: 1428
Joined: Thu May 07, 2015 8:42 am
Contact:

Re: [0.14.22] Arch server connect/reconnect troubles

Post by Oxyd »

I made it so Factorio will put a .lock file into its write-data and call flock(2) on it to ensure no other Factorio process is using the same directory.

Automatically using separate write-data on headless would be more involved, and you'd have to edit the config to change the port anyway. And then we'd likely get a flood of confused server owners asking why the thing won't work with files that are right there in their installation directory. :)

quyxkh
Smart Inserter
Smart Inserter
Posts: 1028
Joined: Sun May 08, 2016 9:01 am
Contact:

Re: [0.14.22] Arch server connect/reconnect troubles

Post by quyxkh »

Oxyd wrote:I made it so Factorio will put a .lock file into its write-data and call flock(2) on it to ensure no other Factorio process is using the same directory.
Thank you!
Oxyd wrote: Automatically using separate write-data on headless would be more involved, and you'd have to edit the config to change the port anyway. And then we'd likely get a flood of confused server owners asking why the thing won't work with files that are right there in their installation directory. :)
Hunh. It works without changing the port for me, I do the copy-config.ini-change-the-write-path ritual above, fire up the server with that config and the moved server-settings.json (and the default port), and connect as usual. Could this be expectation left over from the p2p-networking days, when clients listened too? You can see in the logs that the client is connecting (as I thought was usual for pure clients) from a random port.

But really -- _really_ -- with such a simple workaround it's already fine, and this fix to diagnose the trouble is more than enough. i'll stop distracting y'all from more important work :-)

daniel34
Global Moderator
Global Moderator
Posts: 2761
Joined: Thu Dec 25, 2014 7:30 am
Contact:

Re: [0.14.22] Arch server connect/reconnect troubles

Post by daniel34 »

quyxkh wrote:Hunh. It works without changing the port for me, I do the copy-config.ini-change-the-write-path ritual above, fire up the server with that config and the moved server-settings.json (and the default port), and connect as usual. Could this be expectation left over from the p2p-networking days, when clients listened too? You can see in the logs that the client is connecting (as I thought was usual for pure clients) from a random port.
I think you misquoted here and wanted to refer to the port change I mentioned above.

At least on WIndows you need to change the port of one of the instances (server or client) since both are listening on localhost:34197 by default. This is still true since the client has to listen to the server's messages. If one instance sends a message to the target (localhost:34197) it would be ambiguous which instance actually receives the message, so Windows only allows one process to listen to a specific ip:port pair. If you tried to have a second instance listen on the same ip:port pair you'd get an error. If this is indeed possible and working under Linux then disregard my advice, but I assumed it would behave the same as it would on Windows.
quick links: log file | graphical issues | wiki

quyxkh
Smart Inserter
Smart Inserter
Posts: 1028
Joined: Sun May 08, 2016 9:01 am
Contact:

Re: [0.14.22] Arch server connect/reconnect troubles

Post by quyxkh »

daniel34 wrote:
quyxkh wrote:Hunh. It works without changing the port for me, I do the copy-config.ini-change-the-write-path ritual above, fire up the server with that config and the moved server-settings.json (and the default port), and connect as usual. Could this be expectation left over from the p2p-networking days, when clients listened too? You can see in the logs that the client is connecting (as I thought was usual for pure clients) from a random port.
I think you misquoted here and wanted to refer to the port change I mentioned above.

At least on WIndows you need to change the port of one of the instances (server or client) since both are listening on localhost:34197 by default. This is still true since the client has to listen to the server's messages. If one instance sends a message to the target (localhost:34197) it would be ambiguous which instance actually receives the message, so Windows only allows one process to listen to a specific ip:port pair. If you tried to have a second instance listen on the same ip:port pair you'd get an error. If this is indeed possible and working under Linux then disregard my advice, but I assumed it would behave the same as it would on Windows.
No, that's what I was saying: look at the logs. The server listens on the configured port, and the client connects to the server at that port, but the port the client uses for its own network access is arbitrary and behaves, in the logs I've seen (like the ones posted here) as is usual for client ports, as if it were left unspecified, for the OS to pick from the available ones:

Code: Select all

   0.432 Hosting game at 0.0.0.0:34197
   0.432 Info HttpSharedState.cpp:44: Downloading https://auth.factorio.com/generate-server-padlock
   1.129 Info HttpSharedState.cpp:111: Status code: 200
   1.129 Info AuthServerConnector.cpp:106: Obtained serverPadlock for serverHash (qqz5NYPhMZWqm9qBkGNuzyPhqfs92bl4) from the auth server.
   1.129 Info ServerMultiplayerManager.cpp:658: mapTick(0) changing state from(CreatingGame) to(InGame)
   1.129 Info UDPSocket.cpp:39: Opening socket for broadcast
  33.965 ConnectionRequestReplyConfirm (type(ConnectionRequestReplyConfirm) ) from(192.168.1.2:41192)
  33.965 Refusing connection for address(192.168.1.2:41192). User verification is required for this game.
  34.485 ConnectionRequestReplyConfirm (type(ConnectionRequestReplyConfirm) ) from(192.168.1.2:46679)
  34.485 Info ServerRouter.cpp:413: Replying to connectionRequest for address(192.168.1.2:46679).
See the 41192 and 46679? On linux you can `connect()` using an unspecified source port, the OS picks any available one for you on the theory that when you talk to the server, you and it know what port you used and nobody else cares, so why bother requiring any particular one? On datagram protocols like udp the "connection" is just remembering the address pair, no traffic required, but it's built precisely for usage like this. Works a treat.

Oxyd
Former Staff
Former Staff
Posts: 1428
Joined: Thu May 07, 2015 8:42 am
Contact:

Re: [0.14.22] Arch server connect/reconnect troubles

Post by Oxyd »

I have to admit I've had my various configs with different port numbers since the 0.12 era and never bothered to check if changing the port number is still necessary. You're right that with the new networking model it shouldn't be.

daniel34
Global Moderator
Global Moderator
Posts: 2761
Joined: Thu Dec 25, 2014 7:30 am
Contact:

Re: [0.14.22] Arch server connect/reconnect troubles

Post by daniel34 »

Oxyd wrote:I have to admit I've had my various configs with different port numbers since the 0.12 era and never bothered to check if changing the port number is still necessary. You're right that with the new networking model it shouldn't be.
I just tested this, and I honestly expected that the second instance would throw an error or communication would not be possible, but it just ... works.

I extracted the 0.14.22 .zip to two directories, f1 and f2. I then started the f1 executable and started a new multiplayer game. I then launched f2, went to Multiplayer --> Play on LAN --> joined the existing game and it worked right out of the box.

If you put them side-by-side you can see some latency as expected, but apart from that it's working flawless.

My firewall says that the first process is connecting to 10.0.0.24:34197 (internal WLAN IP) and the second process is listening to 34197<-10.0.0.24, so it seems to be transparent to it. I would have expected some issue along the line, but apparently it just works.
quick links: log file | graphical issues | wiki

Post Reply

Return to “Resolved Problems and Bugs”