Problem with second client joining voice room
VPadu
✭
in Photon Voice
Good day everyone!
I am writing this post because I have a problem with Photon Voice.
My program has two clients joining a room successfully. They also share their webcam so the connection works perfectly.
The problem is that the voice does not: the first client that joins the room correctly joins the voice room as well. The second client who joins can hear the first one, but cannot send its voice through the network; i.e. the first client does not here the second one.
I tried setting the LOG LEVEL to ALL and the image shows what is logged in the console.
This is a loop that goes on forever on the client that joined the room last.
Could you perhaps help me? It would be much appreciated.
Kind regards
I am writing this post because I have a problem with Photon Voice.
My program has two clients joining a room successfully. They also share their webcam so the connection works perfectly.
The problem is that the voice does not: the first client that joins the room correctly joins the voice room as well. The second client who joins can hear the first one, but cannot send its voice through the network; i.e. the first client does not here the second one.
I tried setting the LOG LEVEL to ALL and the image shows what is logged in the console.
This is a loop that goes on forever on the client that joined the room last.
Could you perhaps help me? It would be much appreciated.
Kind regards
0
Comments
-
More info:
The photon voice is set as mentioned in the suggested workflow page so I have a PhotonVoice prefab with PhotonVoiceNetwork, Recorder, PhotonVoiceView and PhotonView components and a speaker prefab0 -
I have a PhotonVoice prefab with PhotonVoiceNetwork1
-
Dear @JohnTube
I now have a game object called PhotonVoiceTest which has the components PhotonVoiceNetwork, Recorder, PhotonView and PhotonVoiceView (instead of a prefab)
And it looks like this:
In this case, the documentation says "Optionally add a PhotonVoiceNetwork to the scene." and now I am not sure if this is the correct way to do it.
I do not have multiple instances of PhotonVoiceNetwork on one client, however each client has its own instance of PhotonVoiceNetwork.
The problem remains: the second client cannot join somehow
Sorry to bother you (maybe it is a very simple thing that I don't understand) but I don't have a lot of experience with unity.0 -
Dear @JohnTube
To answer your questions:
No, the issue does not happen with the demos (the demo I tried is the one with the zombie peluches)
I do not use custom authentication
I use Photon Cloud (I do not have my own server where photon is hosted)
I followed this tutorial to set up the connection.
That means that if no room are found, the client creates a new one and if one is found they connect to it.
The code looks like this
The Photon Voice version is 2.17 which I think is the most recent one
0 -
Hi @VPadu,
Not sure how you ran into this but if it's random it should not persist.
If client disconnects unexpectedly sometimes the server may keep its peer connection alive and relative actor active in the room for 10 seconds before it times out.
if the issue persists and it's 100% reproducible send me a repro project via email to developer@photonengine.com.0 -
Hey @VPadu,
I think that maybe you have multiple PhotonVoiceNetwork instances in your project.
Try changing PhotonVoiceNetwork's instance property code ("Assets\Photon\PhotonVoice\Code\PUN\PhotonVoiceNetwork.cs") with this and see if it helps.
The new code logs errors instead of warnings and auto destroy extra instances.public static PhotonVoiceNetwork Instance { get { lock (instanceLock) { if (AppQuits) { if (instance.Logger.IsWarningEnabled) { instance.Logger.LogWarning("PhotonVoiceNetwork Instance already destroyed on application quit. Won't create again - returning null."); } return null; } if (!instantiated) { PhotonVoiceNetwork[] objects = FindObjectsOfType<PhotonVoiceNetwork>(); if (objects == null || objects.Length < 1) { GameObject singleton = new GameObject(); singleton.name = "PhotonVoiceNetwork singleton"; instance = singleton.AddComponent<PhotonVoiceNetwork>(); if (instance.Logger.IsInfoEnabled) { instance.Logger.LogInfo("An instance of PhotonVoiceNetwork was automatically created in the scene."); } } else if (objects.Length >= 1) { instance = objects[0]; if (objects.Length > 1) { if (instance.Logger.IsErrorEnabled) { instance.Logger.LogError("{0} PhotonVoiceNetwork instances found. Using first one only and destroying all the other extra instances.", objects.Length); } for (int i = 1; i < objects.Length; i++) { Destroy(objects[i]); } } } instantiated = true; } return instance; } } set { lock (instanceLock) { if (value == null) { if (instance.Logger.IsErrorEnabled) { instance.Logger.LogError("Cannot set PhotonVoiceNetwork.Instance to null."); } return; } if (instantiated) { if (instance.GetInstanceID() != value.GetInstanceID()) { if (instance.Logger.IsErrorEnabled) { instance.Logger.LogError("An instance of PhotonVoiceNetwork is already set. Destroying extra instance."); } Destroy(value); } return; } instantiated = true; instance = value; } } } protected override void OnDestroy() { base.OnDestroy(); lock (instanceLock) { if (instantiated && instance.GetInstanceID() == this.GetInstanceID()) { instantiated = false; } } }
0 -
I have a very similar problem, my setup is different and in my case I noticed that when the user that can't be heard changes microphone input (like turning on a bluetooth handsfree or manually changing it in OS settings) then the voice works, I'm trying to work this out too...
I have a single persistent instance of PhotonVoiceNetwork with a recorder and I instantiate (not photon instantiate) local prefabs with a photonview and photonvoiceview to which I then sync phtonviewID's over network
I've tried a number of configurations but none have given me stable results, if you could help I'd be grateful for life.0 -
Dear @JohnTube
The code you gave me helped me discover that there was actually another instance of PhotonVoiceNetwork. I removed the one that I didn't need and the error displayed on the console disappeared (the client does not fail to connect).
The program however still does not work: the second client does not manage to send their voice across the network.
I am going to investigate why this happens and I will write what I discover.
Thanks for the help so far0 -
Dear @JohnTube
I finally solved my problem.
The thing is that I did not completely understand how PhotonVoice works so when another client entered the room, since I do not need this functionality, I did not spawn a player. The PhotonView component was just already present in the scene so that's why it did not work.
Your VoiceDebugScript did not work so reading the discussion that you linked me made me understand how I should have used Photon Voice.
Thank you very much for your help, really.
Hope this discussion will help other people that made the same mistake as me.
Have a nice day everyone0