Connection Issues

Almost every game I play has the same connection issue. Some random number of minutes in, I disconnect from all other players. There is no ICE notification afterwords that it is reconnecting. When I go back to the client, the lobbies are all invalid until I refaf.

This is the error that occurred in the clent log at the time of the DC. Note that I left the game 2 minutes later:

2022-02-18 22:43:49.565 ERROR 1016 --- [reactor-tcp-nio-2] com.faforever.commons.lobby.FafLobbyApi  : Inbound channel closed with error

java.net.SocketException: Connection reset
    at java.base/sun.nio.ch.SocketChannelImpl.throwConnectionReset(SocketChannelImpl.java:367)
    at java.base/sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:398)
    at io.netty.buffer.PooledByteBuf.setBytes(PooledByteBuf.java:253)
    at io.netty.buffer.AbstractByteBuf.writeBytes(AbstractByteBuf.java:1132)
    at io.netty.channel.socket.nio.NioSocketChannel.doReadBytes(NioSocketChannel.java:350)
    at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:151)
    at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:722)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:658)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:584)
    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:496)
    at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:986)
    at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
    at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
    at java.base/java.lang.Thread.run(Thread.java:832)

This is one of many similar errors that occured for each player at the time of the DC in the ICE log (I also briefly DCed from another player about a minute earlier, and that caused the same error):

2022-02-18 22:43:49.526 WARN  ICE DemonicRaptor(61395): Failed to send data via ICE (c.f.iceadapter.ice.PeerIceModule:388)
java.net.SocketException: No buffer space available (maximum connections reached?): no further information
    at java.base/sun.nio.ch.DatagramChannelImpl.send0(Native Method)
    at java.base/sun.nio.ch.DatagramChannelImpl.sendFromNativeBuffer(DatagramChannelImpl.java:897)
    at java.base/sun.nio.ch.DatagramChannelImpl.send(DatagramChannelImpl.java:859)
    at java.base/sun.nio.ch.DatagramChannelImpl.send(DatagramChannelImpl.java:817)
    at java.base/sun.nio.ch.DatagramChannelImpl.blockingSend(DatagramChannelImpl.java:849)
    at java.base/sun.nio.ch.DatagramSocketAdaptor.send(DatagramSocketAdaptor.java:217)
    at java.base/java.net.DatagramSocket.send(DatagramSocket.java:532)
    at org.ice4j.socket.DelegatingDatagramSocket.send(DelegatingDatagramSocket.java:732)
    at org.ice4j.socket.MergingDatagramSocket$SocketContainer.send(MergingDatagramSocket.java:1003)
    at org.ice4j.socket.MergingDatagramSocket$SocketContainer.access$100(MergingDatagramSocket.java:650)
    at org.ice4j.socket.MergingDatagramSocket.send(MergingDatagramSocket.java:207)
    at org.ice4j.socket.DelegatingDatagramSocket.send(DelegatingDatagramSocket.java:776)
    at org.ice4j.socket.IceUdpSocketWrapper.send(IceUdpSocketWrapper.java:53)
    at com.faforever.iceadapter.ice.PeerIceModule.sendViaIce(PeerIceModule.java:386)
    at com.faforever.iceadapter.ice.PeerIceModule.onFaDataReceived(PeerIceModule.java:373)
    at com.faforever.iceadapter.ice.Peer.faListener(Peer.java:82)
    at java.base/java.lang.Thread.run(Thread.java:832)

Complete log files:
client.log
ice-adapter.log
game_16393918.log

Thanks for the help!

Looks to me like either there's a network error causing data to pile up or you are opening too many sockets. You could take a look at how many sockets there are open on your machine and which application created them.

This might also help, although I have no idea about the side effects:
https://customer.precisely.com/s/article/How-to-resolve-java-net-SocketException-No-buffer-space-available-maximum-connections-reached-error-in-Spectrum?language=en_US

Having issues with connectivity / ICE? Talk to me.

If that is the case, then FAF is almost certainly leaking sockets. My system only has ~200 TCP sockets open at idle, and only ~10 of those are in active use at any given time.

I wrote a little script to monitor it and log the TCP port count and activity. Hopefully my next game will reveal the issue.