Actor.UserID blank

JPGOrdon
JPGOrdon
edited October 2020 in Photon Server
I have an extremely peculiar case in which my plugin an Actor has a blank UserId. It is hard to reproduce but, after OnCreateRoom the only active actor has a blank UserID (it is equal to ""). I use a timer to delay it (tried upto 1000ms) and tried using info.UserId and searching through all active actors, but the UserID is still blank.

I use custom authentication and the UserID issued by the WS. What are the cases in which an Actor's UserID should be blank? Even if the WS denied the player auth, would the UserID be blank?

I am quite stumped. Help would be awesome. I am using the latest photon server V4-29-11263

Comments

  • hi, @JPGOrdon

    this could be some issue. What is `WS` in your message? what are you doing? could you collect debug logs and provide them to us?

    best,
    ilya
  • JPGOrdon
    JPGOrdon
    edited November 2020
    chvetsov wrote: »
    hi, @JPGOrdon

    this could be some issue. What is `WS` in your message? what are you doing? could you collect debug logs and provide them to us?

    best,
    ilya

    My web server works via postman and works every time as expected. However, in some scenarios, the Info.UserId from ICreateGameCallInfo is equal to "". I also can assert that my WS functions correctly in this scenario because my client does not get a custom authentication error.

    Do I need to set a delay before reading Info.UserId from ICreateGameCallInfo? Should I be accessing the Actor in a different way for the ICreateGameCallInfo call?
  • hi, @JPGOrdon
    you do not have to keep any delay before reading. Please try photon 5 beta, if you still will have issue there than we will try to find out what happened. Probably it is a bug

    best
    ily
  • @chevetsov I will try Photon 5 Beta. At this moment, I believe I was experiencing a bug on your end. By my own testing, I have eliminated the client or the WS authentication as the root of the problem. It seems like no matter what I do, I encounter a situation where Info.UserId returns blank.

    Is there a load balancing application I can use for Photon v5, or should I follow your upgrade guide and manually upgrade my load balancing project?
  • hi, @JPGOrdon

    Photon 5 has similar structure. Same LoadBalancing project and same load balancing application. so you may use it

    best,
    ilya
  • JohnTube
    JohnTube ✭✭✭✭✭
    Hi @JPGOrdon,

    The UserID issue you see in v4 is probably related to this:
    The server does not return the UserId in case not set by client or auth provider. The value should be a GUID generated on the server. This may result in players not being able to join rooms with error code -2 (error message: "Join failed: UserId is not set, checkUserIdOnJoin=true expects a UserId."). As a workaround, client C# SDKs now send a GUID as UserId if it is not explicitly set by the user.
    source

    I join my colleague @chvetsov in recommending v5.
    Otherwise a workaround would be to make sure to set a UserID from client or custom authentication provider during authentication.
  • JPGOrdon
    JPGOrdon
    edited November 2020
    @chvetsov @JohnTube Thank you for your time and recommendations.

    Your analysis is correct, it seems to be an issue with the Client not setting a UserId as the log reads:
    ...Join failed: UserId is not set
    

    However, I connect with PUN using one function that, most of the time, preforms as expected. In some instances with the same function, my server reads that the clients UserId is not set. Here is my PUN code (I doidn't know where to place this conversation)
    AuthenticationValues authValues = new AuthenticationValues();
            authValues.AuthType = CustomAuthenticationType.Custom;
            authValues.AddAuthParameter("uid", settings.uid);
            authValues.AddAuthParameter("token", settings.token);
            PhotonNetwork.NetworkingClient.AuthValues = authValues;
            if (PhotonNetwork.NetworkingClient.State == ClientState.ConnectedToMaster) { // connected to master may not be called if user still connected, invoke manually
                PhotonNetwork.JoinRandomRoom();
            } else {
           PhotonNetwork.ConnectToMaster(playerData["masterServerAddress"].Value, API.MasterServerPort, "");
            }
    
    I am enormously frustrated because I can assert that the AuthenticationValues and their parameters are being set correctly each time, especially for the case when the server will then not read the client's UserId.
    After failure from UserId not being set, the client can reinvoke the above function and connection and authentication works as expected (keep in mind the parameters I provide are not changing either).

    Is this in-fact a client issue, or still a problem that upgrading to V5 would solve?

    PS: I would be more than happy to move/create a new post on the PUN section if my issue is client related.
  • @JPGOrdon I do not know whether you changes in server code much but if not than all migration should look like starting another version of photon.

    yeah, it will be good to ask in PUN section of forum about PUN code. this is not my strong side. Usual issue with client side code is that it is called at not right time. however I think it is not your case.

    Please try photon 5. After that we will try to understand deeper what might be wrong

    best,
    ilya
  • JohnTube
    JohnTube ✭✭✭✭✭
    Hi @JPGOrdon,

    About the PUN client code snippet:

    Does your configured custom authentication provider's endpoint return a UserId in the JSON response?
    If not, add it.

    Otherwise, ff the settings.uid (or another value known by the client) is the actual UserId then add this line:
    authValues.UserId = settings.uid;
    
  • @JohnTube My web server provides the UserId each time. I am frustrated because the code will not work and then the same code will work right after.
  • JohnTube
    JohnTube ✭✭✭✭✭
    Is this in-fact a client issue, or still a problem that upgrading to V5 would solve?
    This is still an issue on the server I think but a client code could be a workaround.
    Do you change room creation options? maybe RoomOptions.PublishUserId?
    I'm out of ideas and the usual reports we got about v4 UserID issue is that it's not returned to client ALL the time, in your case it's about the plugin and it's random.
    So I still prefer if you give v5 a quick try.