On joining a room, I get an error when I try to set my voice groups.

The whole answer can be found below.

Please note: The Photon forum is closed permanently. After many dedicated years of service we have made the decision to retire our forum and switch to read-only: we've saved the best to last! And we offer you support through these channels:

Try Our
Documentation

Please check if you can find an answer in our extensive documentation on Voice.

Join Us
on Discord

Meet and talk to our staff and the entire Photon-Community via Discord.

Read More on
Stack Overflow

Find more information on Stack Overflow (for Circle members only).

Write Us
an E-Mail

Feel free to send your question directly to our developers.

On joining a room, I get an error when I try to set my voice groups.

ShadowToast
2020-01-13 14:16:43

Hello,

When I join a room, I am added to a 'zone' which has it's own voice group - to ensure each zones chat is private.
To handle this, on moving to the zone this code is called:

if (updatedUser == myUser)  
        {  
            byte[] groupToRemove = voiceGroup;  
            if (zoneLocations.Contains(newLocation))  
            {  
                byte index = Convert.ToByte(zoneLocations.IndexOf(newLocation) + 1);  
                voiceGroup = new byte[] { index };  
                PhotonVoiceNetwork.Instance.Client.OpChangeGroups(groupToRemove,  voiceGroup);  
            }  
            PhotonVoiceNetwork.Instance.PrimaryRecorder.InterestGroup = voiceGroup[0];  
        }

However, on entering the room I am getting this error:
"Operation ChangeGroups (248) not allowed on current server (NameServer)"

I am passing in a default value of '7' as a byte (it's what voiceGroup is set to initially).
Every time I change zone after this, the above code works perfectly and I can only hear those in my zone.

I've tried searching for what causes this, especially considering I am definitely in a photon room when the above code is called.

Any ideas?

Comments

JohnTube
2020-01-13 15:46:46

Hi @ShadowToast,

Photon Voice integration with PUN works with two clients: PUN client and Voice client.
The way the integration works is that the PUN client first joins a PUN room THEN the Voice client joins a voice room.

So I think what's happening here is that you are trying to set interest groups for the Voice client too early, you try to set interest groups for the voice client after the PUN client joined a room BUT before the Voice client finishes joining a room.

So you need to wait until

PhotonVoiceNetwork.Instance.ClientState == ClientState.Joined

ShadowToast
2020-01-14 12:32:35

@JohnTube So this looked like exactly what I needed.
I am having some issues though.

The setting:

PhotonVoiceNetwork.Instance.AutoConnectAndJoin = true;

Doesn't seem to work, as when I join a room the following happens:

public override void OnJoinedRoom()  
    {  
        StartCoroutine(SetVoiceSettingsToDefault());          
    }

    private IEnumerator SetVoiceSettingsToDefault()  
    {  
        do  
        {  
            yield return new WaitForEndOfFrame();  
        } while (PhotonVoiceNetwork.Instance.ClientState != ClientState.Joined);  
        UpdateAudioByLocation(defaultLocation, myUser);  
        yield return null;  
    }  

The first time I join a room it works fine, but when I leave to the lobby and join a new room it gets stuck in the coroutine do loop as the client state is never 'Joined'.

I tried calling connect and join for the photon voice network before starting the coroutine to wait for the connection. It mostly failed to connect entirely.

Edit 1:
I imagine this happens due to the client state not being connected to the master server when I attempt to connect.
When I disconnect from a room, return to the lobby and join a new room the voice client state never changes from disconnected.
Do I have to instigate a 'connect to master, connect to room' each time?
Edit 2:
I checked in the above coroutine whether or not the client state is disconnected, and if it is to call connect with settings (as auto connect doesn't work), the client state changes as follows:
First time I join:
ConnectedToNameServer,
ConnectingToMasterserver,
Authenticating,
ConnectingToGameserver,
Joining,
Joined

Joining a new room:
ConnectedToNameServer,
ConnectingToMasterserver,
Authenticating,
ConnectedToMaster (Which is odd, as this state is shown as depreciated)

When it gets to here it stalls, and I attempt to connect and join.
No dice:

[Voice.PhotonVoiceNetwork] Connecting to server failed.

JohnTube
2020-01-15 10:05:40

Hi @ShadowToast,

This is a known issue, already fixed but the fix is not released yet.
It will be out in the next version.

Replace PhotonVoiceNetwork with this version.

Thank you for your understanding and patience.

ShadowToast
2020-01-15 10:58:40

Hey @JohnTube,

This seems to have fixed it, brilliant!
If I have any issues, I'll make a new post.
As far as I'm concerned this is exactly what I needed.

I look forward to the next version!

Thanks.

JohnTube
2020-02-03 11:26:37

Hi @ShadowToast,

I just submitted version 2.13 to the Unity Asset Store.
It contains the updated version of PhotonVoiceNetwork fixed.

Thanks again for your patience and understanding.

Michael_Watkins
2022-08-20 17:48:28

Last time this came up was in 2020 and @JohnTube said it was fixed just not released yet. Has that release gone out?

My chat works just fine in global mode when working on interest group 0 but when i go to change it is when i get the 248 error. The link to the fix is not there.

for code im using this

void setTeam(byte teamNumber)  {

if (view.IsMine) {

PhotonVoiceNetwork.Instance.Client.OpChangeGroups(null, new byte[1] { teamNumber });

FindObjectOfType<Photon.Voice.Unity.Recorder>().InterestGroup = teamNumber;

  }

}

vadim
2022-08-22 08:49:14

What is the 248 error?

What was fixed in 2020? Maybe you have a link to a thread or other clue?

Michael_Watkins
2022-08-24 13:04:50

This thread. The original poster had the same problem as me

"Operation ChangeGroups (248) not allowed on current server (NameServer)"

vadim
2022-08-24 15:49:38

This error means that the voice client is not joined to a room when you are trying to change interest group with OpChangeGroups() call

Michael_Watkins
2022-08-25 11:07:52

vadim 2022-08-24T15:49:38+00:00

This error means that the voice client is not joined to a room when you are trying to change interest group with OpChangeGroups() call

ah ha. that makes sense. Do i need to use some sort of callback that will let me know it has joined so that i can then go ahead and change the interest group?

Michael_Watkins
2022-08-25 12:50:26

never mind i kinda fudged it and now it works

void Update()

{

if (!hasJoined && PhotonVoiceNetwork.Instance.ClientState.ToString() == "Joined")

{

hasJoined = true;

battleManager.PlayerM.setVoiceGroup(battleManager.PlayerM.teamName);

}

}

Back to top