Failed to instantiate object in OnJoinedRoom callback
Options
Hi,
I am using PUN(v1.9) and local Photon server(4.0.29.11263).
I want to instantiate a network object by PhotonNetwork.Instantiate in OnJoinedRoom() like:
public override void OnJoinedRoom()
{
PhotonNetwork.Instantiate(myPrefabName, ...);
}
However sometimes the object is not instantiated in other clients. The issue usually happened on the user who joined later, for example: 7 users already in the room and the issue happened on the 8th user.
I found some logs near the timing of issue happened.
PUN:
Operation 253 could not be executed (yet). Wait for state JoinedLobby or ConnectedToMaster and their callbacks before calling operations. WebRPCs need a server-side configuration. Enum OperationCode helps identify the operation.
Server:
2018-11-28 10:48:37,531 [37] DEBUG Photon.SocketServer.PeerBase - SentOpResponse: Peer=GameClientPeer: PID 3660, IsConnected: True, IsDisposed: False, Last Activity: Operation 253 at UTC 11/28/2018 2:48:37 AM in Room M63H, IP 10.116.132.147:62574, , opCode=253, return=-3(Operation is not allowed on this join stage), ChannelId=0 result=Ok size=53 bytes
Does that mean even if client has got OnJoinedRoom callback but the server is not ready to raise event?
Thank you.
I am using PUN(v1.9) and local Photon server(4.0.29.11263).
I want to instantiate a network object by PhotonNetwork.Instantiate in OnJoinedRoom() like:
public override void OnJoinedRoom()
{
PhotonNetwork.Instantiate(myPrefabName, ...);
}
However sometimes the object is not instantiated in other clients. The issue usually happened on the user who joined later, for example: 7 users already in the room and the issue happened on the 8th user.
I found some logs near the timing of issue happened.
PUN:
Operation 253 could not be executed (yet). Wait for state JoinedLobby or ConnectedToMaster and their callbacks before calling operations. WebRPCs need a server-side configuration. Enum OperationCode helps identify the operation.
Server:
2018-11-28 10:48:37,531 [37] DEBUG Photon.SocketServer.PeerBase - SentOpResponse: Peer=GameClientPeer: PID 3660, IsConnected: True, IsDisposed: False, Last Activity: Operation 253 at UTC 11/28/2018 2:48:37 AM in Room M63H, IP 10.116.132.147:62574, , opCode=253, return=-3(Operation is not allowed on this join stage), ChannelId=0 result=Ok size=53 bytes
Does that mean even if client has got OnJoinedRoom callback but the server is not ready to raise event?
Thank you.
0
Best Answer
-
hi, @iruan0820
I have been thinking about a fix for this issue. I think best of all would be fix checks in HivePeer.cs
you will be able to find there checks like this: this.JoinStage != JoinStages.Connected
you should change it to this.JoinStage != JoinStages.PublishingEvents
best,
ilya5
Answers
-
hi, @iruan0820
The thing is that we send User Join Response before some few steps. you may find them in HiveGame.JoinSendResponseAndEvents. Well, this means that your server is under high load because I would expect that 20-40 milliseconds is more than enough to execute the rest of the method.
you may update code to set 'Complete' state earlier. That is all that I could advise.
I'm very interested in knowing what is your server load
best,
ilya0 -
hi, @iruan0820
I have been thinking about a fix for this issue. I think best of all would be fix checks in HivePeer.cs
you will be able to find there checks like this: this.JoinStage != JoinStages.Connected
you should change it to this.JoinStage != JoinStages.PublishingEvents
best,
ilya5 -
@iruan0820 did you do your tests locally when experiencing this issue? I mean whether server and clients are started on the same machine?
best,
ilya0 -
yes, one day we will
I do not have exact dates
best,
ilya0 -
@iruan0820 could you try another fix?
In HiveGame.JoinSendResponseAndEvents method we set states of a peer. I assume that this could be some kind of caches update bug. where one thread does not see yet the state of another one. I just can not believe that the server is not able to finish this method while network packets go to a client and back.
so, for the fix, we should revert HivePeer to the previous state and replace all code like 'peer.JoinStage = HivePeer.JoinStages.GettingUserResponse;' in the method to Interlocked.Exchange(ref peer.JoinStage, HivePeer.JoinStages.GettingUserResponse);
peer.JoinState should be updated to be 'int' field.
if this will fix your issue then we will stop on this fix
best,
ilya
0