beeeen
beeeen2mo ago

Players Are Disconnecting Randomly

Recently, our players have reported disconnecting randomly from the game without warning. This has been reported to happen upon connecting to a room as well as while playing in a room. We don't receive many errors. However, in editor, we sometimes get issues connecting to rooms. It appears to happen this way: 1. We attempt connection to a room by calling realtime.Connect with the medium room size. 2. We get the debug log from Realtime: "Realtime: Connection to room '<room name>'" 3. Because normcore takes a long time, we call realtime.Connect with the same room name every second for 10 seconds. 4. Because we're still disconnected, we attempt a realtime.Connect call with a different room name. 5. We get the debug log from Realtime: "Realtime: Connection to room '<room name>'" 6. Then we get an error message from realtime: "Realtime (native): BidirectionalClient: Connection Error: Unable to connect to normcore-matcher.normcore.io on port 3000, error: No such host is known. 7. Our system then kicks the player back out to the main menu because they were disconnected for too long. A couple of notes about the screenshot: 1. I haven't yet turned on "debug logging". I'll do that soon. 2. The "Cannot set lifetime flags on model ..." error has happened for months now and hasn't broken anything. Therefore, we can suppose that it's unrelated.
No description
6 Replies
kapa.ai
kapa.ai2mo ago
Hi @beeeen. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- Based on the information you've provided, it seems you're experiencing connection issues with Normcore. Let's address the problems you're facing: 1. Random disconnections: This could be related to network instability or firewall issues. Normcore uses specific ports and IP ranges for communication. Make sure your network allows the required ports and IP ranges as specified in the Firewalls + Corporate Networks (https://normcore.io/documentation/architecture/firewalls) documentation. 2. Connection attempts and errors: Your connection process has a few issues that could be causing problems: a) Calling realtime.Connect() multiple times: You should not call realtime.Connect() repeatedly while a connection attempt is in progress. This can lead to unexpected behavior. Instead, wait for the connection to complete or timeout before trying again. b) Changing room names during connection attempts: Changing the room name while still attempting to connect to the previous room can cause conflicts. It's better to fully disconnect before trying to connect to a different room. c) Host resolution error: The error "Unable to connect to normcore-matcher.normcore.io on port 3000, error: No such host is known" suggests a DNS resolution problem. This could be due to network issues or firewall restrictions. To address these issues, try the following: 1. Implement a proper connection flow: - Call realtime.Connect() once - Use the didConnectToRoom event to know when the connection is successful - Use the didDisconnectFromRoom event to handle disconnections - Implement a timeout mechanism instead of repeatedly calling Connect() Here's an example of how you might implement this:
public class ConnectionManager : MonoBehaviour
{
[SerializeField] private Realtime _realtime;
[SerializeField] private float _connectionTimeout = 30f;
private float _connectionStartTime;

private void Start()
{
_realtime.didConnectToRoom += DidConnectToRoom;
_realtime.didDisconnectFromRoom += DidDisconnectFromRoom;
}

public void ConnectToRoom(string roomName)
{
_connectionStartTime = Time.time;
_realtime.Connect(roomName, new Room.ConnectOptions
{
roomServerOptions = new Room.RoomServerOptions
{
configuration = "medium"
}
});
StartCoroutine(CheckConnectionTimeout());
}

private void DidConnectToRoom()
{
Debug.Log("Connected to room successfully");
// Handle successful connection
}

private void DidDisconnectFromRoom()
{
Debug.Log("Disconnected from room");
// Handle disconnection
}

private IEnumerator CheckConnectionTimeout()
{
while (!_realtime.connected)
{
if (Time.time - _connectionStartTime > _connectionTimeout)
{
Debug.Log("Connection timed out");
_realtime.Disconnect();
// Handle timeout (e.g., show error message, return to main menu)
yield break;
}
yield return null;
}
}
}
public class ConnectionManager : MonoBehaviour
{
[SerializeField] private Realtime _realtime;
[SerializeField] private float _connectionTimeout = 30f;
private float _connectionStartTime;

private void Start()
{
_realtime.didConnectToRoom += DidConnectToRoom;
_realtime.didDisconnectFromRoom += DidDisconnectFromRoom;
}

public void ConnectToRoom(string roomName)
{
_connectionStartTime = Time.time;
_realtime.Connect(roomName, new Room.ConnectOptions
{
roomServerOptions = new Room.RoomServerOptions
{
configuration = "medium"
}
});
StartCoroutine(CheckConnectionTimeout());
}

private void DidConnectToRoom()
{
Debug.Log("Connected to room successfully");
// Handle successful connection
}

private void DidDisconnectFromRoom()
{
Debug.Log("Disconnected from room");
// Handle disconnection
}

private IEnumerator CheckConnectionTimeout()
{
while (!_realtime.connected)
{
if (Time.time - _connectionStartTime > _connectionTimeout)
{
Debug.Log("Connection timed out");
_realtime.Disconnect();
// Handle timeout (e.g., show error message, return to main menu)
yield break;
}
yield return null;
}
}
}
2. Enable debug logging: As you mentioned, enabling debug logging can provide more information about what's happening during the connection process. You can do this by setting _realtime.debugLogging = true;. 3. Check network and firewall settings: Ensure that your network allows the required ports and IP ranges for Normcore as specified in the Firewalls + Corporate Networks (https://normcore.io/documentation/architecture/firewalls) documentation. 4. Consider room server configuration: You're using the "medium" room server configuration. Depending on your needs, you might want to adjust this. The Room Server Configurations (https://normcore.io/documentation/room/room-server-options#room-server-configurations) documentation provides details on the available options. 5. Investigate the "Cannot set lifetime flags on model" error: While you mentioned this error hasn't caused issues, it's worth investigating to ensure it's not related to your connection problems. This error typically occurs when trying to set lifetime flags on a model that hasn't been fully initialized yet. If you continue to experience issues after implementing these changes, I recommend reaching out to the Normcore support team or community for further assistance, as they may be able to provide more specific guidance based on your exact setup and usage patterns. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai2mo ago
<@690217885540417680> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
beeeen
beeeenOP2mo ago
Okay, I'll adjust our connection flow and see how that goes. Thank you!
maxweisel
maxweisel2mo ago
No such host is known is a DNS resolution issue This isn’t even getting to the point of having an IP address to connect to our servers I can help with the lifetime flags but too (probably benign) but I’d need to see the line of code that’s resulting in that error. what’s the stack trace? for DNS resolution, this can happen for a myriad of reasons unfortunately, but it’s usually the network device configuration as it’s responsible for DNS resolution annoyingly some ISPs furnish their own DNS servers that can fail requests occasionally. it can be worth setting your DNS server list on your machine to 8.8.8.8 (Google DNS) to rule that out
beeeen
beeeenOP2mo ago
So it would be a per-client thing since every client has their own DNS, correct?
maxweisel
maxweisel2mo ago
if you’re seeing the same error on all clients it would be a per-client issue. there’s always the possibility our DNS records have an issue but I’d expect a large outage from that

Did you find this page helpful?