Search Unity

Third Party Photon Unity Networking

Discussion in 'Multiplayer' started by tobiass, Aug 23, 2011.

  1. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,070
    @Le_Hieu: This sounds like an issue with the code stripping. You can create a link.xml file that protects the SocketWebTcp from being stripped.

    @Alex3333: It's not recommended to update PUN individually, when using Photon Voice.
    Due to the changes in PUN 2, the Photon Voice package also needs to be updated.
    In the coming days, Photon Voice will be updated accordingly.
     
  2. Le_Hieu

    Le_Hieu

    Joined:
    Mar 26, 2011
    Posts:
    31
    @tobiass: Could you give more specific instructions? I am very newbie. Thank you
     
  3. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,070
    @Le_Hieu : The instructions for the link.xml file are coming from Unity and are pretty complete and understandable, as far as I remember.

    As per the error message, you want to make sure ExitGames.Client.Photon.SocketWebTcp is not stripped. It's part of the project and part of a assembly definition (PhotonWebSocket.asmdef is in the same folder).

    So in the link.xml, you need an entry like:
    Code (xml):
    1. <assembly fullname="PhotonWebSocket">
    2.     <type fullname="ExitGames.Client.Photon.SocketWebTcp" preserve="all"/>
    3. </assembly>
    Hope that helps.
     
    Le_Hieu likes this.
  4. Meceka

    Meceka

    Joined:
    Dec 23, 2013
    Posts:
    423
    I have updated Photon to 2.14. Using Unity 2017.4.30f1 and I started getting these errors every time I enter play mode, launch unity, open/switch a scene or do similar things. Before update (I think my version was 2.13) I never got these errors.

    Edit: It happens in Singleplayer or Menu too, when no photon functions are getting called.

    Code (CSharp):
    1. NotSupportedException: The invoked member is not supported in a dynamic module.
    2. System.Reflection.Emit.AssemblyBuilder.get_Location () (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection.Emit/AssemblyBuilder.cs:241)
    3. Photon.Pun.PhotonEditor.UpdateRpcList () (at Assets/Photon/PhotonUnityNetworking/Code/Editor/PhotonEditor.cs:690)
    4. Photon.Pun.PhotonEditor.OnInitialHierarchyChanged () (at Assets/Photon/PhotonUnityNetworking/Code/Editor/PhotonEditor.cs:201)
    5. UnityEditor.EditorApplication.Internal_CallHierarchyWindowHasChanged () (at C:/buildslave/unity/build/Editor/Mono/EditorApplication.cs:153)
    Code (CSharp):
    1. NotSupportedException: The invoked member is not supported in a dynamic module.
    2. System.Reflection.Emit.AssemblyBuilder.get_Location () (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection.Emit/AssemblyBuilder.cs:241)
    3. Photon.Pun.PhotonEditor.UpdateRpcList () (at Assets/Photon/PhotonUnityNetworking/Code/Editor/PhotonEditor.cs:690)
    4. Photon.Pun.PhotonEditor.OnDidReloadScripts () (at Assets/Photon/PhotonUnityNetworking/Code/Editor/PhotonEditor.cs:190)
     
  5. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,070
    @Meceka: We tested several versions and thought we are covering this case. Very annoying indeed. And it breaks RPC method detection, too.

    Update: It seems there are one case we can't reliably cover with compile conditions. If you run .Net 3.5 for UWP with 4.6 API compatibility. Of course, there is still a solution for this...

    You can fix this in PhotonEditor.cs by putting this into line 680:
    System.Reflection.Assembly[] assemblies = System.AppDomain.CurrentDomain.GetAssemblies().Where(a => !(a.ManifestModule is System.Reflection.Emit.ModuleBuilder)).ToArray();

    Remove the following lines of code with compile conditions. This makes the line 682 the next one with the foreach.


    Let me know if this works. If not, let me know your project and build settings: Platform, Scripting Runtime, etc.

    Thanks for the clear report.
     
    Last edited: Aug 15, 2019
  6. Meceka

    Meceka

    Joined:
    Dec 23, 2013
    Posts:
    423
    It's not UWP but a console. Scripting Runtime is set to .Net 3.5, I'm not sure about 4.6 API compatibility.

    So should I make #if !UNITY_ConsoleName to those lines?

    Thank you.
     
    Last edited: Aug 15, 2019
  7. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,070
    The new line that I posted above should work in all export settings (so no ifdef needed). As said, you have to get rid of the previously used code to select the Assemblies.
    Anything that's console specific has to be discussed via mail: developer@photonengine.com.
     
  8. DavidSWu

    DavidSWu

    Joined:
    Jun 20, 2016
    Posts:
    183
    With the latest release PhotonEditor.cs seems to have regressed slightly with the Linq change:
    Line 697 should be changed to:
    Code (CSharp):
    1.                 var additional = methodNames.Where(n => !serverSettings.RpcList.Contains(n) && !additionalRpcs.Contains(n) ) ;
    2.  
    And Line 671:
    Code (CSharp):
    1.  if (!serverSettings.RpcList.Contains(methodInfo.Name) && !additionalRpcs.Contains(methodInfo.Name) )
     
  9. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,070
    @DavidSWu: Good catch, thanks. Yes, the check for duplicates was missing. We can do a fix release early next week, I think.
     
  10. DavidSWu

    DavidSWu

    Joined:
    Jun 20, 2016
    Posts:
    183
    No problem. I tried clearing my RPC's to rebuild them and it told us that we needed to use a short to represent them, at first I thought someone on the team had gone RPC crazy...
    It is interesting that we can save on RPC's (should we get close to the limit) by re-using names across classes. We had assumed that they had to be unique, so we embedded class names in them i.e. "RPCPlayerCharacterTakeDamage" etc.
     
  11. Alex_Heizenrader

    Alex_Heizenrader

    Joined:
    May 16, 2019
    Posts:
    95
    I am getting the following error since updating to the last version 2.14

    upload_2019-8-27_21-13-52.png

    I tried debugging since it seems it is receiving some strange data from whoever is controlling the object in question, and debugging the stream.ReceiveNext(); that is supposed to set this.m_Direction, I saw a Vector4 instead of a vector3 which is what causes the invalid cast and freaks out about it. I am not sure why this is happening though.
     
  12. Alex_Heizenrader

    Alex_Heizenrader

    Joined:
    May 16, 2019
    Posts:
    95
    I changed my transformviews to the tranformviewclassic ones and I get the same error, this time it is localized to the rotation, I get a cast invalid to a quaternion and if I debug it i see that is is because I am getting a Vector3 (0,0,0) from the stream instead of a quaternion. The photonviews are unreliable on change,and it happens only at the beginning of starting the change, in case that helps.

    Pun:2.14 Photon lib:4.1.2.17
     
    Last edited: Aug 28, 2019
  13. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,070
    As you say, this will be related to the data that gets sent.
    Maybe you modified the PhotonTransformView or observe yet another script on the object (which contributes to sending/receiving data)?
    So far, this was not reported, so we could use your setup. A minimal project to look at would be nice to have (via mail).
     
  14. Ayfel

    Ayfel

    Joined:
    Feb 28, 2015
    Posts:
    13
    I didnt modify transformview or transformviewclassic and it keeps hapenning. As for other objects being observed, I am observing several transformviews in one photonview that is parent to all of them. So one parent observes all the children transformviews (to save on messages), maybe this is the problem but it was working just fine before updating. I will try later to set up a minimal case.

    After more testing it keeps happening when starting a change. I am using the transformview to sync changes in position and scale simultaneously (i am scaling manually from a different pivot so position and scale change at the same time, I also track rotation but at different times/input). It is set as unreliable on change because it doesnt change often only at the users input. So everytime the changes start this error pops up and data seems to get mingled.
     
    Last edited: Aug 28, 2019
  15. Alex_Heizenrader

    Alex_Heizenrader

    Joined:
    May 16, 2019
    Posts:
    95
    I just regressed to Photon 2.10 to test and it solved the issue ( I couldn't find the 2.12 package which was the one I was using before updating), so it must be something in the new version

    UPDATE: Actually after playing a bunch with it I have seen that error appear but it happens very rarely now, again same situation, on start of changes (but not always just sometimes), with a photon view observing several transform views...it used to block my vr headset before but it doesn't now which is maybe why I never noticed with old versions. To give you some indication of how, I used to get dozens and dozens of the error and now I am getting it 2 or 3 times only.

    Also it appears even when changing to "unreliable" (instead that unreliable on change) or even reliable, only that it appears at different deserializations (position, or rotation, or m_SynchronizedTurnSpeed,etc), but always an unexpected cast of data, most likely because of mingling. It is very strange because I have not modified photon's source code at all, just using the transformviews provided

    LAST UPDATE: I found a rogue script that was doing transformView.m_SynchronizePosition = false; for one of the observed components for a couple of frames before reactivating it, this must be the source of all since it fixed the errors. I don't understand very well why it makes the stream of data fail but it is sensible that it could happen. I refactored it to fix it and now everything is good.

    P.S: I am almost 100% sure this didn't use to happen and it is something I have seen more recently in the last 2/3 weeks
     
    Last edited: Aug 28, 2019
  16. w34edrtfg

    w34edrtfg

    Joined:
    Nov 23, 2014
    Posts:
    72
    Hi @tobiass i hope you can share this message with all Photon team:
    I recently recovered a 2015 project (Unity 5) that made use of Photon and i've been able to make it work with latest Photon versions with almost no effort. It's incredible to achieve that consistency during 4/5 years!
    Thank you for building a solution that has always been better than the official one!
     
  17. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,070
    @Alex_Heizenrader: Thanks for the updates. Glad you found that script. It's plausible that this caused the issues:
    Very likely, the script only changed m_SynchronizePosition on one client, so the receiving end still expected this value to be incoming. This means the reading side was one off for the remainder of the stream.

    @w34edrtfg: Thanks for your feedback - much appreciated!


    What keeps happening? How many objects do you observe (maximum)? A repro would be nice to have but if possible, we would try to help you find the solution. Let us know more. You can also mail: developer@photonengine.com
     
  18. Omris

    Omris

    Joined:
    Aug 7, 2017
    Posts:
    3
    Can anyone help me pls about ,how can make 2d shop system on photon . Please Help
     
  19. payalzariya07

    payalzariya07

    Joined:
    Oct 5, 2018
    Posts:
    85
    In photon Network how to invite friends in Rooms?

    PUN2
    -> if i am create room and this room i am create multiple rooms , is this Possible in pun2 .

    if is possible.

    how i can do in PUN2?
     
  20. roka

    roka

    Joined:
    Sep 12, 2010
    Posts:
    598
    @tobiass I have moved on the version v1.99 (20. August 2019) but i have a warning spam "Deserializing OpResponse Ping." on the console. Like my target is WebGL, this can have an impact on the performance. Can you tell us if you can fix it soon?

    Thank you.
     
  21. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,070
    @roka: I think it should be fixed internally already. You can comment out the respective line without side-effect, right now, too. Thanks for the heads up.

    @payalzariya07: PUN can only join one room at a time.
    For friends and invitations, you need some room-independent communication backend. E.g. PlayFab or Player.Io, etc.
    https://doc.photonengine.com/en-us/pun/v2/lobby-and-matchmaking/userids-and-friends

    @Omris: That's not exactly our topic with Photon. If you want in game purchases, take a look at Player.Io and PlayFab (and others)...
     
  22. roka

    roka

    Joined:
    Sep 12, 2010
    Posts:
    598
    @tobiass Sorry, but i think that the call back come from the dll. I have tried to find "Deserializing OpResponse Ping" on the complete solution in order to edit it myself, but it do not appear anywhere.

    *** Alright, editing Debug.LogWarning(message); from IPhotonPeerListener in NetworkingPeer.cs:1600 temporary fix the problem.
     
    Last edited: Sep 9, 2019
    tobiass likes this.
  23. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,070
    You are right, it's from within the DLL. I guess you could also set a lower logging level (in the PhotonServerSettings) to avoid this.
    It's only happening in TCP and WS/WSS connections and will be removed in the next update PUN v2.15.
     
  24. newlife

    newlife

    Joined:
    Jan 20, 2010
    Posts:
    1,081
    How to implement this? I didnt find anything in PUN documentation.
     
  25. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,070
    The video just explains the architecture of PUN. You download and use it.
    Can you elaborate what you need / expect?
     
  26. newlife

    newlife

    Joined:
    Jan 20, 2010
    Posts:
    1,081
    Im talking about advance relay architecture. Did you see the video?
    I want to use the room as a lightweight dedicated server.

     
  27. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,070
    That is what Photon implements.
    An easy start to use this is to get PUN 2 from the Asset Store and run some demo. Most of those connect and join into a random room and there you are. Aside from using PUN features, you can use RaiseEvent to exchange your own, custom messages, too

    See:
    https://doc.photonengine.com/en-us/pun/v2/getting-started/pun-intro

    There is typically no custom server logic for this. If that's needed, look into the Photon Server SDK and "Plugins":
    https://doc.photonengine.com/en-us/server/current/getting-started/photon-server-intro
     
  28. newlife

    newlife

    Joined:
    Jan 20, 2010
    Posts:
    1,081
    You are saying that its not possible to have a a lightweight dedicated server with server side logic as stated in the video by Christof Wegmann (CTO of Exit Games)?
     
  29. newlife

    newlife

    Joined:
    Jan 20, 2010
    Posts:
    1,081
  30. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,070
  31. newlife

    newlife

    Joined:
    Jan 20, 2010
    Posts:
    1,081
    you are not answering the question. Is not possible anymore to have a lightweight dedicated server with server side logic as stated in the video by Christof Wegmann (CTO of Exit Games)?

    What do you mean? you give access to this only to "selected" customers?
     
  32. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,070
    My problem is that I am trying to understand your motivation.
    If you just insist on an answer for your yes/no question, here we go: "No".

    To clarify: It is possible to run logic in the server side and it will act as if it's a lightweight dedicated server. Use server plugins. It's available for all customers.
     
  33. newlife

    newlife

    Joined:
    Jan 20, 2010
    Posts:
    1,081
    You cant understand my motivation? Just listen to Christof Wegmann in the video.
    Lightweight dedicated server is super cost effective (10 times cheaper than headless server) and just works every time.
    Not only, lightweight dedicated server doesn't need to be hosted somewhere, while headless server must be hosted somewhere and its not reliable (as stated on your own bolt page: "Uses Unity on the server, potential stability / memory / CPU issues").
    Same thing with server plugins. server plugins are available only with photon server, that clearly must be hosted somewhere.
    So, once and for all, can you please tell why you removed the server side code from advance relay architecture?
     
  34. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,070
    The "advanced relay" architecture describes what Photon does on the server side for the PUN client.
    Unlike a plain network relay, the Photon Servers can be used to store events and properties of the room and players. In some cases, these features can be used instead of writing (and hosting) custom logic. This is client driven. For example, the feature "Check and Swap" for properties can be used in a way to determine which player gets a pickup, etc.
    This is available on the Photon Cloud.
     
  35. newlife

    newlife

    Joined:
    Jan 20, 2010
    Posts:
    1,081
    Ok.
    Are you referring to webhooks? Cause I read on webhook FAQ page (https://doc.photonengine.com/en-us/pun/current/gameplay/web-extensions/webhooks-faq):

    -----
    Is There Any Interesting Use Case For Webhooks Other Than Storing And Retrieving The Room's State?
    Well, there are many things possible with webhooks :)

    Here's a list of few :

    • Server side authoritative code:
      This can be useful when some specific game logic need to be executed at server side only.
    • Protection against malicious hackers:
      Webhooks can also be handy when it comes to detect cheaters. PathProperties and PathEvent webhooks can be used to authorize players' actions from server side code.
    -----

    Can you please tell how this can be implemented?
     
  36. newlife

    newlife

    Joined:
    Jan 20, 2010
    Posts:
    1,081
  37. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,070
    We submitted PUN v2.15 to the Asset Store. Here's what's new and fixed:

    v2.15 (19. September 2019)
    Fixed: NullReferenceException when trying to log an error for a received RPC with a non existing method and zero arguments.
    Changed: Calling an RPC method with a null or empty method name will not be executed and error will be logged.
    Fixed: Callbacks deregistration and PlayersPerTeam clearing in PunTeams which caused KeyNotFoundException in some cases.
    Fixed: NullReferenceException in SupportLogger.TrackValues in Unity Editor after compilation by making sure only one instance of SupportLogger is in the scene and SupportLogger.TrackValues is properly stopped when the application stops or client disconnects.
    Changed: TypedLobby refactored to reflect the proper definition of the default lobby: a lobby that has a null or empty name, the provided type is ignored in this case and will be considered default type.
    Changed: RPC methods not found error logs explictily state that RPC methods search does not include static methods which are not supported as RPC methods.
    Updated: SceneSettings Inspector improved and SceneAsset field added to make reference to scenes easier.
    Updated: Code comments for documentation.
     
  38. Shadowing

    Shadowing

    Joined:
    Jan 29, 2015
    Posts:
    1,648
    @tobiass The Photon Chat server must be down?

    Edit: its been over 3 hours now still down.
     
    Last edited: Sep 22, 2019
  39. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,070
    If there are issues, please report per mail: developer@photonengine.com. We don't monitor this place as closely and it will help to know the region and whatever else you can point out.
    We don't see any bigger issues with Chat.
     
  40. digiross

    digiross

    Joined:
    Jun 29, 2012
    Posts:
    323
    PUN really looks like what I need to use and wondered what is the latest unity version this works with? 2019.2?
     
  41. Jean-Fabre

    Jean-Fabre

    Joined:
    Sep 6, 2007
    Posts:
    429
    Hi,

    Yes, all public releases of Unity will work starting from 2017 LTS. 2019.3 beta might work as well, but we can't guarantee it since it's still in beta.

    Be,

    Jean
     
    digiross likes this.
  42. digiross

    digiross

    Joined:
    Jun 29, 2012
    Posts:
    323
    Ok thanks. I'm starting a new project this weekend :c)
     
  43. Kirby26

    Kirby26

    Joined:
    Mar 3, 2019
    Posts:
    13
    Can someone explain me the thing of 20 Concurrent users? its in the same room? Or your max players in general of the online game is 20? or thats unity users editing the game?
     
  44. Jean-Fabre

    Jean-Fabre

    Joined:
    Sep 6, 2007
    Posts:
    429
    Hi,

    20 CCU means that you can't have more than 20 players in total across all your rooms for a given App ID, so it's not in the same room, but across all rooms. as a developer inside Unity editor, if you connect and join/create a room, it will count as 1 concurrent user.

    Bye,

    Jean
     
  45. Koval331

    Koval331

    Joined:
    Feb 3, 2019
    Posts:
    114
    I have not found any info in the description of PhotonView and in the tutorials (yet) about the meanings of those "things". What are observer options and how to use them? And where can I find info about them?
    • Reliable Delta Compressed
    • Unreliable
    • Unreliable On Change
    capt.png
     
  46. Jean-Fabre

    Jean-Fabre

    Joined:
    Sep 6, 2007
    Posts:
    429
    Hi,

    We are going to update to doc to feature this, as you are right, information can be clearer on this topic, meanwhile, here's the rundown:

    - Off
    Synchronization does not occur, nothing is sent or received
    - Reliable Delta Compressed
    Data is guaranteed to be received with an internal optimization mechanism which sends null if data doesn’t change. For this to work, make sure you populate the stream with distinct .sendnext() commands.
    - Unreliable
    Data is received in order but some updates may be lost. This means no delay in cases of loss.
    - Unreliable OnChange
    Data is received in order but some updates may be lost. If updates repeat the last information, the Photon View will pause sending updates until the next change.

    Bye,

    Jean
     
    artsapplesoftware and JohnTube like this.
  47. rasto61

    rasto61

    Joined:
    Nov 1, 2015
    Posts:
    352
    Im getting this:
    Connect failed. SocketImplementationConfig is null for protocol WebSocket: {(ConnectionProtocol)Udp=(RuntimeType)ExitGames.Client.Photon.SocketUdpAsync, (ConnectionProtocol)Tcp=(RuntimeType)ExitGames.Client.Photon.SocketTcpAsync}
    on 2.15/ 4.1.2.17 in the Editor targeting standalone. Targeting webgl, it works fine.
     
  48. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,070
    The transport protocol in the PhotonServerSettings should be set to UDP in best case. WebGL will use WSS automatically (no matter what is set, in fact) as that's the only option for that export.

    This will get rid of the issue.
    WebSockets are not included in all builds at the moment. To add them, put the compile define "WEBSOCKET" in the respective build and setup the websocket-sharp.dll to export (via inspector).
     
    rasto61 likes this.
  49. Koval331

    Koval331

    Joined:
    Feb 3, 2019
    Posts:
    114
    Thanks for your reply! Now, could you clarify what: "make sure you populate the stream with distinct .sendnext() commands" means? I would love to know that for my project.
     
  50. Rmzn0

    Rmzn0

    Joined:
    Jul 24, 2018
    Posts:
    9
    I want to make a 4-player co-op game by purchasing Asset.

    Is it possible with your asset?