Alix Ollivier
Alix Ollivier2mo ago

Full room disconnects everyone

When I have more than 8 players join a small room, they all disconnect.
18 Replies
kapa.ai
kapa.ai2mo ago
Hi @Alix Ollivier. 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 provided in the knowledge sources, it appears that you may be encountering an issue related to room capacity. Let's address this problem: The Room Server Options documentation provides insights into the capacity of different room server configurations. For a small room server, which is likely what you're using, the typical capacity for a VR title is around 16 players. However, if your application includes voice chat, this number drops to about 8 players. Given that you're experiencing disconnections when more than 8 players join, it's possible that: 1. Your room is configured as a small server with voice chat enabled, reaching its capacity limit. 2. Your application might be using more bandwidth than a typical VR title, reducing the effective player count. To resolve this issue, you have a few options: 1. Upgrade to a larger room server configuration. For example, a medium configuration could potentially support up to 20 players for a VR title with voice chat. 2. Optimize your application to reduce bandwidth usage. As mentioned in the How room servers scale section, "reducing the data a single player sends by 64 bytes leads to a total bandwidth saving of 1,024 bytes for the entire room server." 3. If possible, consider splitting your space across multiple Normcore rooms to distribute the player load. To upgrade your room server, you can use the Room Server Options API when connecting to a room. Here's an example of how to connect to a medium-sized room:
_realtime.Connect("My Room", new Room.ConnectOptions {
roomServerOptions = new Room.RoomServerOptions {
configuration = "medium"
}
});
_realtime.Connect("My Room", new Room.ConnectOptions {
roomServerOptions = new Room.RoomServerOptions {
configuration = "medium"
}
});
Remember, the room server configuration is set by the first player to connect and cannot be changed during the session. If you need to change the configuration, all players must disconnect, and the room must be idle for 30 seconds before a new configuration can be applied. If you continue to experience issues or need more specific guidance, you may want to contact Normcore support directly, as they might be able to provide more tailored advice based on your specific implementation and usage patterns. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai2mo ago
<@185325614775926784> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
Alix Ollivier
Alix OllivierOP2mo ago
@Normcore Assistant is there any way to try connecting to a room and stop the player if the room is full?
kapa.ai
kapa.ai2mo ago
Let me check the knowledge base for you again. One moment! :books: ---------------------- To address your question about trying to connect to a room and stopping the player if the room is full, I'll need to provide some context and then explain the available options based on the information from the Normcore documentation. Unfortunately, there isn't a direct, built-in method to check if a room is full before connecting. However, we can implement a workaround using the existing Normcore APIs. Here's an approach you could consider: 1. Attempt to connect to the room. 2. Monitor the connection state. 3. If the connection fails due to the room being full, prevent the player from joining. Here's a basic implementation of this approach:
using Normal.Realtime;
using UnityEngine;

public class RoomConnectionManager : MonoBehaviour
{
[SerializeField] private Realtime _realtime;

private void Start()
{
// Subscribe to the connection state changed event
_realtime.didConnectToRoom += DidConnectToRoom;
_realtime.didDisconnectFromRoom += DidDisconnectFromRoom;

// Attempt to connect to the room
ConnectToRoom();
}

private void ConnectToRoom()
{
_realtime.Connect("RoomName", new Room.ConnectOptions {
roomServerOptions = new Room.RoomServerOptions {
configuration = "small" // or whatever size you're using
}
});
}

private void DidConnectToRoom(Realtime realtime)
{
Debug.Log("Successfully connected to the room!");
// Proceed with your game logic for a connected player
}
private void DidDisconnectFromRoom(Realtime realtime)
{
if (realtime.disconnectReason == DisconnectReason.RoomIsFull)
{
Debug.Log("Failed to connect: Room is full!");
// Implement your logic to handle a full room (e.g., show a message to the player)
}
else
{
Debug.Log($"Disconnected from room. Reason: {realtime.disconnectReason}");
}
}

private void OnDestroy()
{
// Unsubscribe from events
if (_realtime != null)
{
_realtime.didConnectToRoom -= DidConnectToRoom;
_realtime.didDisconnectFromRoom -= DidDisconnectFromRoom;
}
}
}
using Normal.Realtime;
using UnityEngine;

public class RoomConnectionManager : MonoBehaviour
{
[SerializeField] private Realtime _realtime;

private void Start()
{
// Subscribe to the connection state changed event
_realtime.didConnectToRoom += DidConnectToRoom;
_realtime.didDisconnectFromRoom += DidDisconnectFromRoom;

// Attempt to connect to the room
ConnectToRoom();
}

private void ConnectToRoom()
{
_realtime.Connect("RoomName", new Room.ConnectOptions {
roomServerOptions = new Room.RoomServerOptions {
configuration = "small" // or whatever size you're using
}
});
}

private void DidConnectToRoom(Realtime realtime)
{
Debug.Log("Successfully connected to the room!");
// Proceed with your game logic for a connected player
}
private void DidDisconnectFromRoom(Realtime realtime)
{
if (realtime.disconnectReason == DisconnectReason.RoomIsFull)
{
Debug.Log("Failed to connect: Room is full!");
// Implement your logic to handle a full room (e.g., show a message to the player)
}
else
{
Debug.Log($"Disconnected from room. Reason: {realtime.disconnectReason}");
}
}

private void OnDestroy()
{
// Unsubscribe from events
if (_realtime != null)
{
_realtime.didConnectToRoom -= DidConnectToRoom;
_realtime.didDisconnectFromRoom -= DidDisconnectFromRoom;
}
}
}
This script attempts to connect to a room and listens for connection events. If the connection fails because the room is full, it will be caught in the DidDisconnectFromRoom method, where you can implement your logic to stop the player from joining and perhaps display a message. It's worth noting that this approach will still attempt to connect before determining if the room is full. If you need a more efficient solution or want to avoid unnecessary connection attempts, you might consider: 1. Implementing a custom matchmaking system that keeps track of room occupancy. 2. Using Normcore Private, which may offer more advanced room management features. Remember, as mentioned in the Common Questions section:
"How do I get a list of all rooms and how many players are in them? This is something we're working on, but for the time being, it's something you'll need to manage yourself."
This suggests that Normcore doesn't currently provide a built-in way to check room occupancy before connecting, which is why we need to use the workaround described above. If you need more precise control over room occupancy and connections, you might want to reach out to Normcore support for additional guidance or to inquire about upcoming features that might address this need more directly. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai2mo ago
<@185325614775926784> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
maxweisel
maxweisel2mo ago
these answers are wrong it shouldn’t be disconnecting everyone if it’s full you’ll just see packets start to stutter this sounds like a bug but I’m not sure what in Normcore would disconnect everyone the builds don’t crash or anything? No disconnect errors?
Mechabit
Mechabit2mo ago
maybe you have code that joins and disconnects when you find a full room. instead you should use a lobby service
Alix Ollivier
Alix OllivierOP2mo ago
I don't have any code related to normcore connection afaik. It's just the "login on start" option
Mechabit
Mechabit2mo ago
I use unity lobby to check for available rooms
Mikameel
Mikameel2mo ago
@Alix Ollivier do you have paid normcore? I tested Normcore free and I got only to 7 VR players, maybe new connections get bounced ? idk
Alix Ollivier
Alix OllivierOP2mo ago
I have normcore free for now @Mechabit , would you be willing to share your unity lobby code?
Mechabit
Mechabit2mo ago
after you've set up lobbies you want to add the normcore room name as meta data
Mechabit
Mechabit2mo ago
string lobbyName = "new lobby"; int maxPlayers = 4; CreateLobbyOptions options = new CreateLobbyOptions(); options.Data = new Dictionary<string, DataObject>() { { "Room", new DataObject( visibility: DataObject.VisibilityOptions.Public, // Visible publicly. value: "Normcore Room Name") }, }; Lobby lobby = await LobbyService.Instance.CreateLobbyAsync(lobbyName, maxPlayers, options); I usually name my lobbies after the host player name When a player joins a lobby they can read the "Room" data from the lobby and use Realtime.Connect(room name); to connect Or you can just share the room name with your friends
maxweisel
maxweisel2mo ago
@Alix Ollivier happy to help debug. Any logs you can share?
Alix Ollivier
Alix OllivierOP5w ago
@maxweisel I never ended up logging anything, and I have since changed how the lobby system works, so I'm unclear if this is still an issue. I went back into my old footage and found this: https://youtube.com/shorts/ShJfrUFGupg?feature=share Is there a way I can make 8 bot normcore players to test if the issue is still there / test my new lobby sorting system?
maxweisel
maxweisel5w ago
The easiest approaches to export headless clients and run them on your computer. We have a “fake vr player” rig that moves the head and hands for our title for this. You can get away with quite a lot of bot clients on a typical VR dev PC. Once you outgrow that, we generally recommend wrapping them in a docker image and using something like kubernetes to spin up hundreds of replicas in the cloud. That can get pretty expensive though. One thing worth noting, we have an update rolling out in a month or so that has updated disconnect events that will give you the exact reason a client disconnected. And if it’s a Normcore related bug or server crash, it will include the metadata needed to send it to us to debug. I’ll make a post in the changelog channel when that release goes live If you use anything for analytics, saving that data to your analytics platform (Amplitude or MixPanel for example) is a great way to track it without having to collect player logs Services like Sentry are also great for collecting all player logs too if you do ever want to go that route

Did you find this page helpful?