Search Unity

Photon Unity Networking

Discussion in 'Connected Games' started by tobiass, Aug 23, 2011.

  1. Rob-161

    Rob-161

    Joined:
    Dec 1, 2016
    Posts:
    18
    Thanks heaps! Works fine. So just another question....now I am still a newbie when it comes to programming, let alone networking, but after reading/watching a few tutorials on using Photon for my turn-based game, I understand that using Photon Events is the way to go when it comes to sending/receiving data between players. What I want to know though is to what extent should I raise events. Say for example, in my game I move a unit, then attack an enemy, the enemy gets wounded and blood marks the ground. In this instance, I would raise an event to show my unit has moved, then another event to update the enemy's reduced health. If I have a bleeding particle effect attached to the enemy which becomes active when wounded, would I need to raise an event for this too or this there an easier way to sync this with the other player? Same goes with blood mark that hits the floor... Thanks in advance!
     
  2. Munchy2007

    Munchy2007

    Joined:
    Jun 16, 2013
    Posts:
    1,077
    To a certain degree it's down to personal preference how you approach it (either with RPCs or RaiseEvent). My personal preference is to use RaiseEvent, because it gives me more control over which clients/scripts receive and handle the events; however, it probably adds a little more complexity compared with using RPCs.

    But you would need to do one or the other to synchronise things like bleed particles as per your example, and the chances are once you've had a bit more time at it, you'll make up your own mind which you think is the easiest way.
     
  3. Rob-161

    Rob-161

    Joined:
    Dec 1, 2016
    Posts:
    18
    When I read about using RPCs, it actually sounds more suited to what I want to do and simpler. However on the Photon website, it suggests not using RPCs and sticking with Raise Event. See below which I've copied from their page. This is what confuses me on how to proceed....

    Do's and Don'ts
    Creating a turn-based game using PUN implies the correct use of PUN features as well as avoiding certain features not supported in turn-based context.

    Don'ts
     
    Last edited: Sep 11, 2018
  4. Munchy2007

    Munchy2007

    Joined:
    Jun 16, 2013
    Posts:
    1,077
    If you think that RPCs will do the job, then go with them for now.

    In the long run you won't really know until you start to develop the game; if you find that the limitations of RPCs and PhotonViews mentioned in the do's and don'ts cause too many problems then switch to RaiseEvent. That's pretty much how it went for me.

    I rarely use PhotonViews and PhotonNetwork.Instantiate now, the only exception is for the player's game character and possibly for any objects that are controlled solely by the local player, but aren't children of the player gameobject, which need to be removed if the player leaves; I don't use RPCs at all.
     
    Last edited: Sep 11, 2018
  5. Smart-hawk1

    Smart-hawk1

    Joined:
    May 23, 2017
    Posts:
    244
    what alternative you use to PN.Instantiate ?
     
  6. Munchy2007

    Munchy2007

    Joined:
    Jun 16, 2013
    Posts:
    1,077
    I use RaiseEvent to send a buffered message to all clients which when they receive it causes them to use the standard Unity Instantiate to create the object. There also usually needs to be a corresponding event that is used to destroy the object on all clients when required (and which clears the buffered instantiation events);

    Using variations of this method gives the option to spawn objects only on certain clients if required, which can help with interest management.
     
  7. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    2,125
    I just realized how misleading the doc is, re-reading it with your context. Sorry.
    The doc you found, refers to doing asynchronous games with PUN and "Photon Turnbased". In that case, the server will store the room state, when players leave and it will load the state, when the room later gets re-joined. This later rejoin does not work well with PUN's use of the server and thus, the warning to avoid the PhotonView.

    If your game is played in one session but simply turnbased (not stored to play asynchronous), then you can use the PhotonViews and PN.Instantiate just fine.
     
  8. Jean-Fabre

    Jean-Fabre

    Joined:
    Sep 6, 2007
    Posts:
    317
    Hi,

    I can't repro this neither. could you maybe send us a repro project, isolating this issue? thanks :)

    Bye,

    Jean
     
  9. Rob-161

    Rob-161

    Joined:
    Dec 1, 2016
    Posts:
    18
    Thanks for the help and suggestions guys. I've got a much a better understanding now on how I will proceed.
     
    tobiass likes this.
  10. dlevel

    dlevel

    Joined:
    Mar 23, 2016
    Posts:
    268
    is there any chance for an integration with ORK Framework and PUN2?
     
  11. Munchy2007

    Munchy2007

    Joined:
    Jun 16, 2013
    Posts:
    1,077
    Wouldn't that be a job for the developers of ORK?
     
    tobiass likes this.
  12. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    7,668
    I need to send a UInt64 (an Oculus user ID) via custom properties. But attempting to do so in the obvious way results in:

    Since I don't have access to Protocol18Write.cs, I can't easily see what types it does support. But I guess this isn't one of them.

    Do I have to bit-split my ulong into two ints, or is there an easier way?
     
  13. Munchy2007

    Munchy2007

    Joined:
    Jun 16, 2013
    Posts:
    1,077
    tobiass and JoeStrout like this.
  14. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    2,125
    We submitted a new PUN 2 version to the Asset Store and it should be available soon. Here's what's new:

    v2.1 (13th September 2018)
    Fixed: PunTurnManager fully ported to the new PUN 2 API.
    Fixed: SlotRacer Player Control was not setup properly when joining late.
    Fixed: Room is now properly cleaned up when unwanted disconnection occurs.
    Fixed: WebGL exports can also use the new serialization protocol v1.8 (GpBinaryV18). Clients no longer have to set anything manually when mixing WebGL and other exports for cross platform games.
    Fixed: Before calling OnPhotonSerializeView on observed scripts, each PhotonView checks the component's isActiveAndEnabled. This better matches previous logic, where inactive objects are not running.
    Changed: Internals of PhotonNetwork.Instantiate and .Destroy. The process is streamlined and always uses a PrefabPool. The DefaultPool works as before: It loads Resources and actually Destroys them. A custom pool may actually reuse objects and doesn't have to load prefabs from Resources.
    Added: DefaultPool class, which is a simple remake of the previous workflow with prefabs and resources.
    Changed: The LevelPrefix is now a byte value. It was a short, even though PUN always just sent a byte. It's not changed otherwise and pending an overhault to become more usable.
    Changed: AllocateViewId() and AllocateSceneViewId() now have a PhotonView as parameter. This allocates the viewId and applies it right away. Due to that, we no longer need a workaround for "allocated but not yet used" viewIds.
    Removed: PhotonNetwork.ObjectPool value. Use PrefabPool to set a new pool.
    Removed: UnAllocateViewID(). You no longer have to return any viewIDs, not even manually allocated ones.
    Changed: SendInstantiate and ServerCleanInstantiateAndDestroy (called by an object's Destroy) now reuse their Hashtables for the events and the RaiseEventOptions. This reduces GC.
    Changed: Internally, PUN stores which prefabs don't implement IPunInstantiateMagicCallback. This avoids calling GetComponents more than once in best case.
    Changed: The Asteroids demo caches a list of available rooms now.
     
    Munchy2007 and JoeStrout like this.
  15. Smart-hawk1

    Smart-hawk1

    Joined:
    May 23, 2017
    Posts:
    244
    I have a list of Transforms that I want to send over the network regularly there is 2 options

    1. is to make a for loop and RPC the string name of each of the transforms, and on receive find the GO that has that name, i don't like this method since it will create multiple RPCs.

    2. Is to RPC a byte[] which contain each of the transform PhotonView ID, on receive find those IDs and convert to transform list, assuming the id will always be unique

    or is there better option?
     
  16. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    2,125
    You could implement IPunObservable in a script and put this into the "Observed" list of the PhotonView(s).
    If a PhotonView doesn't write to the Stream, it's not sending anything, so you could skip updates at will.
     
  17. Smart-hawk1

    Smart-hawk1

    Joined:
    May 23, 2017
    Posts:
    244
    This is what i currently have, the objective here is to send currLockedTargetList (a transform list) to everyone, so first code is from caller, I make string arraypopulate it with currLockedTargetList object names then RPC that, the other code ifind the object names (obviously will change this, probably find from a list) and populate the currLockedTargetList

    is this method fine or can it be improved?

    Edit: List Array

    Code (CSharp):
    1. if (Input.GetKeyUp(Key))
    2. {
    3.    string[] targetNamesToSend = new string[5];
    4.    for (int i = 0; i < currLockedTargetList.Count)
    5.    {
    6.         targetNamesToSend[i] = currLockedTargetList[i].Name;
    7.    }
    8.  
    9.   photonView.RPC("RPC_ShootOnTargets", photonTargets.Others, targetNamesToSend);
    10.  
    11. }
    Code (CSharp):
    1. [PunRPC]
    2. private void RPC_ShootOnTarget(string [] _targetNames)
    3. {
    4.  
    5.     for (int i = 0; i < _targetNames.Length)
    6.     {
    7.           if (_targetNames[i] != ""){
    8.               Transform newTarget = GameObject.Find(_targetNames[i]).transform;
    9.               if (newTarget != null)
    10.                    currLockedTargetsList.Add (newTarget);
    11.           }
    12.     }
    13. }
     
  18. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    2,125
    You can use the PhotonView.viewID for networked objects instead of the string. That's less traffic.
     
  19. ShinigamiUzi

    ShinigamiUzi

    Joined:
    Sep 5, 2017
    Posts:
    53
    Hi, Not to hijack current discussion but i'm new to networking and Interested to know, how to know what is less traffic? what would be lighter than other etc..

    for example: ownerID is usually a smaller number than ViewID, does it mean ownerID is "lighter", or differences are too little ?
     
    Last edited: Sep 19, 2018
  20. Munchy2007

    Munchy2007

    Joined:
    Jun 16, 2013
    Posts:
    1,077
    It's mainly down to the size of the data type, so in your example OwnerID and viewID would be the same size as they are both ints which are 4 bytes in size. Whereas sending the player's name as a string will almost certainly result in sending more than 4 bytes, as each character in the name is a byte (unless they have a very short name).

    You could reduce the amount of data you send by casting ints to bytes, in cases where you know the value won't exceed 255 for example.
     
    tobiass likes this.
  21. Munchy2007

    Munchy2007

    Joined:
    Jun 16, 2013
    Posts:
    1,077
    Is there an equivalent to static PhotonPlayer.Find(int ID) in PUN2?

    At the moment I'm using the instance version PhotonNetwork.LocalPlayer.Get(int ID), but it just feels a bit long winded to me.
     
  22. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    2,125
    There is no longer a static method for this. PhotonNetwork.CurrentRoom.GetPlayer() would be my choice for this. The room "contains" the players.
     
    Munchy2007 likes this.
  23. AntySK

    AntySK

    Joined:
    Aug 30, 2013
    Posts:
    28
    Hello,
    about new photon 2, did you improve also limit for msg/s in the room ? It would be great to have more than 20 players in one room.
     
  24. Munchy2007

    Munchy2007

    Joined:
    Jun 16, 2013
    Posts:
    1,077
    Okay, thanks I'll use that instead.
     
    tobiass likes this.
  25. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    2,125
    @AntySK: The limits are the same. You can reach about 30 player by using the built in Interest Management but beyond that, we guess it becomes an uphill battle without the help of server side interest management. Can be done with Server Plugins potentially but we didn't dive deep into this yet.

    We updated the PUN v2.1 package in the Asset Store with (only) a new PunCockpit-Scene.unity. It sets the scene's camera Clear Flags to "Don't Clear". The camera was added to avoid having no camera in the scene, which gets you a Unity warning (despite being a UI-only scene). This fixes the black screen over any demo which uses the cockpit.
    This has no new Asset Store version number! Download and import. Another update is upcoming for next week.
     
  26. Timboc

    Timboc

    Joined:
    Jun 22, 2015
    Posts:
    24
    Hi Jean,

    Sorry I didn't see any notification of a new reply - this morning I started setting up a blank project to reproduce it - only to discover whatever changes you have made in v2.1 has fixed the issue for me I think so nice one, thanks!
     
    tobiass likes this.
  27. ThySpektre

    ThySpektre

    Joined:
    Mar 15, 2016
    Posts:
    41
    Does anyone have a method, using PUN, to create an index of players currently in the room? This would be a unique, reusable ID per player. Thus for an 8 player game, each player would have an ID from 0 to 7. If player 0 and player 1 were in a room and player 0 left, player 1 would remain player 1 but player 0 would be open again for the next person who joined.

    This is purportedly what the included Photon utility:
    Photon Unity Networking > Utility Scripts > PhotonPlayer > PlayerRoomIndexing

    but that code does not work.
     
  28. mcbauer

    mcbauer

    Joined:
    Oct 10, 2015
    Posts:
    356
    Is the current documentation on the product page out of date?

    I'm trying to follow this https://doc.photonengine.com/en-us/pun/current/demos-and-tutorials/pun-basics-tutorial/lobby and was brought there through the in-game link for the basic tutorial.

    And it won't compile, even after copying and pasting the code.
    1. There are no includes to anything Photon in the example code provided on the page.
    2. You've capitalized many, I assume all, of your methods now, but the example code still has Camel Case.
    3. autoJoinLobby is gone
    4. PhotonNetwork.ConnectUsingSettings () no longer takes an argument
     
  29. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    2,125
    mcbauer likes this.
  30. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    2,125
    v2.2 (27th September 2018)
    Added: Assembly Definitions for Unity 2017.3 and up. PUN, Realtime, Chat, the WebSocket folder and some Editor classes are now assemblies and will recompile less frequently.
    Added: Chat Demo. An updated version of the UI from PUN Classic.
    Fixed: PunCockpit integration fixed, scene camera was not set properly. This fixes the black screen over any demo which uses the cockpit.
    Fixed: OnCustomAuthenticationFailed() was not virtual in MonoBehaviourPunCallbacks. Now it is and you can override it.
    Changed: Custom editor for PhotonServerSettings, which hides AppIdVoice and AppIdChat when the APIs are not present in a project.
    Removed: PhotonNetwork.InstantiateInRoomOnly. If you need to instantiate game objects before getting into a room, assign a PhotonView and PhotonView.viewID, when you arrive in a room.
     
    Munchy2007 likes this.
  31. mcbauer

    mcbauer

    Joined:
    Oct 10, 2015
    Posts:
    356
    @tobiass Yes this seems to be the correct one thank you.

    Just a reminder to update the link within P2 demo to point to the correct URL.

    Only thing I'm not seeing so far is the "Connected to masterserver" log.

    I get:
    PUN got region list. Going to ping minimum regions, based on this previous result summary: us;20;asia,....
    then it skips available regions and ends with:
    Received your UserID from server. Updating local value to: 6bfca470-....

    I've let this run for a while, I'm assuming this masterserver log should have been with the rest of the logs?

    I get the OnConnectedToMaster() log so I assume things are fine, just wanted to let you know what I was seeing as it compared with the docs.
     
    Last edited: Sep 27, 2018
  32. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    2,125
    I fixed one URL for the update today. Due to the new UI, maybe there's another overlooked link. If you remember which demo had a old link .. please share :)

    The latter should be fine. I guess we're a bit routine-blinded and sometimes overlook changed wording in logs. Thanks for the heads up!
     
  33. mcbauer

    mcbauer

    Joined:
    Oct 10, 2015
    Posts:
    356
    It was the PUNBasics-tutorial demo which had the v1 link.
     
  34. mcbauer

    mcbauer

    Joined:
    Oct 10, 2015
    Posts:
    356
  35. Rob-161

    Rob-161

    Joined:
    Dec 1, 2016
    Posts:
    18
    I've come across a hurdle which I hope someone can assist me with. As soon as my game opens up once selecting join online game from main menu, it closes down and returns to the main menu. As per the log displays, the client tries to join a room, doesn't find one so creates one, the client is in the room, room for 1 gets loaded, local player gets instantiated, PhotonView is registered, and then this error comes up:

    Got a unexpected Disconnect in LoadBalancingClient State: Disconnected. Server: GameServer Trace: at Photon.Realtime.LoadBalancingClient.OnStatusChanged(StatusCode statusCode) in C:\Unity Projects\War Game\Assets\Photon\PhotonRealtime\Code\LoadBalancingClient.cs:line 2302
    at ExitGames.Client.Photon.PeerBase+<>c__DisplayClass100_0.<EnqueueStatusCallback>b__0() in C:\Dev\photon-sdk-dotnet\PhotonDotnet\PeerBase.cs:line 895
    at ExitGames.Client.Photon.EnetPeer.DispatchIncomingCommands() in C:\Dev\photon-sdk-dotnet\PhotonDotnet\EnetPeer.cs:line 429
    at ExitGames.Client.Photon.PhotonPeer.DispatchIncomingCommands() in C:\Dev\photon-sdk-dotnet\PhotonDotnet\PhotonPeer.cs:line 1422
    at Photon.Pun.PhotonHandler.FixedUpdate() in C:\Unity Projects\WarGame\Assets\Photon\PhotonUnityNetworking\Code\PhotonHandler.cs:line 130

    Any advice would be helpful in understanding this error and how to rectify it. Thanks.
     
  36. nsmith1024

    nsmith1024

    Joined:
    Mar 18, 2014
    Posts:
    529
    Im using PUN, is it possible to have 50 or 100 people in the same room? Or maybe 500 to 1000?

    What if i use Photon on the Premises + my own servers, would the above be possible?

    Does Photon on the premises do load balancing?
     
  37. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    2,125
    @mcbauer: Good catch. Thx.

    @Rob-161: From your description, it sounds like the client connected just fine but then either loses the connection when it's been used for a while or something in the game logic causes it to drop. Here is a page to help you analyze it initially:
    https://doc.photonengine.com/en-us/pun/v2/troubleshooting/analyzing-disconnects

    I would suggest trying the "alternative ports" as a first check. Those alternative ports seem to work around issues on PC with some hardware / ISP, which we can't explain entirely.

    @nsmith1024: PUN is not built for 100s of players in a room. We're looking into this but doing it in a generic way (for any type of game) is quite tricky.
    Photon OnPremises is capable of handling several thousand connections, technically. The network interface and connection are the bottleneck here. Albion Online optimized their Photon Servers to handle 300+ players in the same area of a map. A little older but relevant here: http://davidsalz.de/?p=114
     
  38. nsmith1024

    nsmith1024

    Joined:
    Mar 18, 2014
    Posts:
    529
    Ok thanks, great video, really helpful. But it seems this would be an easy feature to incorporate into your existing photon server. You can easily add "In-Range" and "Out-Of-Range" server parameter in your photon server. Both values would represent the distance when an object is considered in range, and the other a distance considered out of range.

    The server would only send update information to objects that were "in-Range" in the SAME ROOM. Objects that were already "in range" would only go "out of range" if they moved further than the "out-of-range" distance.

    The server would send all the missed state information to objects that came "in range", and continue to update it with new information as long as its less than the "out-of-range" distance.

    This would greatly reduce the required bandwidth, increasing the number of players that could be in the same room, and also increase the responsiveness of the game, without forcing all developers write this code ourselves.

    Of course there would need to have a feature where some objects would get updated no matter what the range, this would be just a check box on the PhotonView component added to a gameObject.

    This wont work for every case of course, but it probably would work for 90% of users of photon, and you can have it disabled by default, but it would certainly help increase the number of players in the same room without having all developers write this code themselves.

    This could be an extra marketing feature for your company to sell more photon users since more people could be in the same room with less bandwidth, especially since Unity and Google Cloud is teaming up to create a new massive networking system for unity.

    Do you think your company could add that feature i just mentioned above? It doesnt seem that complicated.

    But I like PHOTON!!

    Is the PHOTON SERVER code available so that we developers can modify it?
     
    Last edited: Oct 3, 2018
  39. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    7,668
    Is there a migration guide from PUN to PUN 2? I'm having to discover myself what the translations are — most things seem to differ mainly in naming and namespaces. Good thing, too, since we have some shared code that's not ready to migrate to PUN 2 in all projects. So I have things like

    #if PUN_2_OR_NEWER
    using Photon.Pun;
    using Photon.Pun.UtilityScripts;
    using PhotonPlayer = Photon.Realtime.Player;
    #endif

    But now I run into something I haven't seen before (e.g. PhotonTargets) and I gave to figure out what that's called now (apparently it's not Photon.Realtime.Targets!). And the docs aren't much help — when I search for stuff, I find myself either randomly in the old docs or in the PUN 2 docs, with no easy way to switch that I can find.

    EDIT: And naturally, after posting this, I promptly stumbled upon this. Sorry for the noise!
     
    tobiass likes this.
  40. Trekopep

    Trekopep

    Joined:
    Dec 18, 2013
    Posts:
    10
    Is there an ETA on the photon transform view component being fixed, so that it shows all the interpolation options and such? (Not in a huge rush, just trying to plan ahead.)
     
  41. summerian

    summerian

    Joined:
    Jul 6, 2014
    Posts:
    114
    [PUN2] When I have the MasterClient send an Allbuffered RCP so that any new clients that connect get it, it seems that the connecting client receives the RPC too early before the view is created. It also looks like the wrong view is targeted?

    How can I fix that?

    What the MasterClient sees


    What the normal client sees upon joining:
     
  42. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    2,125
    @Trekopep: I can't really give a ETA on the settings for the PhotonTransformView, sorry. I hope in this month.

    @summerian: We need a slim repro case for this. Can you send one to developer@photonengine.com and we take a look? Thanks.
     
    Trekopep likes this.
  43. Nikolasio

    Nikolasio

    Joined:
    Dec 6, 2014
    Posts:
    45
    Hi,

    On the server, are RPC's added to a stack, meaning that they are handled chronologically or can there be executed at the same time?
    As I'm working on a race game, after a countdown based on PhotonNetwork.time, time gets measured on two local devices. So the first finisher will send an RPC to run a method on the other device and sets a bool so that this method can't be accessed on his device.
    But in the event of a 'photo' finish:), both players send their RPC simultaneously , is their a way to know which RPC was first (to avoid that both players set the bool and the method isn't called on any device)?
     
  44. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    2,125
    @Nikolasio: RPCs are handled within a room and per room, we only execute one operation at any time. However, the server runs a lot of rooms in parallel.

    In case of a photo finish you'd have to make a choice: Do you want to let the player win who was fastest (measuring the race time and the finish time) or the one who's capable of sending the "i won" first?

    To do the latter, you can use a Custom Room Property. See "Check And Swap for Properties (CAS)" on this page: https://doc.photonengine.com/en-us/pun/current/gameplay/synchronization-and-state

    To do the first, you could either set a property, too, or you send RPCs. Either way, the players would all need to send a "i finished" RPC and when it's clear that there is no photo finish (maybe 1 second after the first "i finished" RPC), you can elect a winner.

    Makes sense?
     
  45. Nikolasio

    Nikolasio

    Joined:
    Dec 6, 2014
    Posts:
    45
    Yes, thx!
     
    tobiass likes this.
  46. Sachinv2

    Sachinv2

    Joined:
    Sep 14, 2018
    Posts:
    2
    Hi All,

    I am having issues connecting to Photon Chat on WebGL platform(It runs absolutely fine on Standalone)

    Getting the following error


    " Connect failed. SocketImplementationConfig is null for protocol WebSocketSecure: {(ConnectionProtocol)Udp=(MonoType)ExitGames.Client.Photon.SocketUdp, (ConnectionProtocol)Tcp=(MonoType)ExitGames.Client.Photon.SocketTcp}
    UnityEngine.Debug:LogError(Object)
    ChatGui:DebugReturn(DebugLevel, String) (at Assets/Photon Unity Networking/Demos/DemoChat/ChatGui.cs:330)
    ExitGames.Client.Photon.Chat.ChatClient:ExitGames.Client.Photon.IPhotonPeerListener.DebugReturn(DebugLevel, String) (at Assets/PhotonChatApi/ChatClient.cs:800)
    ExitGames.Client.Photon.<>c__DisplayClass145_0:b__0()
    ExitGames.Client.Photon.TPeer:DispatchIncomingCommands()
    ExitGames.Client.Photon.PhotonPeer:DispatchIncomingCommands()
    ExitGames.Client.Photon.Chat.ChatClient:Service() (at Assets/PhotonChatApi/ChatClient.cs:269)



    I have already tried all the solutions listed on the forum, but none of them seem to work

    > Made sure the transport protocol is set to WebSocketSecure(Did not work)


    Code (CSharp):
    1. this.chatClient = new ChatClient(this,ConnectionProtocol.WebSocketSecure);
    2. bool isConnecting = this.chatClient.Connect("XYZ", "1.0", new ExitGames.Client.Photon.Chat.AuthenticationValues("USERNAME"));

    > Copied the following code onto ChatPeer to find the "WebSocketType"(Did not work)


    Code (CSharp):
    1. websocketType = websocketType ?? Type.GetType("ExitGames.Client.Photon.SocketWebTcp, Assembly-CSharp", false);
    2. websocketType = websocketType ?? Type.GetType("ExitGames.Client.Photon.SocketWebTcp, Assembly-CSharp-firstpass", false);

    Unity Version : 2018.2.11f1
    Photon Unity Networking 2v2.2


    Can anyone please suggest what i might be doing wrong here?

    Thanks
     
    Last edited: Oct 18, 2018
  47. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    2,125
    @Sachinv2: What platform do you want to export to? We technically only support WebSockets on WebGL and one console.
     
  48. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    2,125
    We just released v2.3 with a few important fixes. See below.

    v2.3 (16th October 2018)
    Fixed: The "Background Fallback Thread".
    PhotonHandler.Awake() now starts the fallback thread which send acks, even if the Main Loop is paused. This was missing and potentially causing timeouts when loading levels.
    Changed: The Background Fallback Thread will keep a connection for another 30 seconds. This is set via ConnectionHandler.KeepAliveInBackground.
    Moved: Instantiation will now call SendInstantiate() earlier to makes sure the event to instantiate is sent (queued) before anything related to the new PhotonViews. This fixes issues when calling an RPC right within Awake() of a new object.
    Added: Check in Instantiate, if the prefab has a PhotonView. Logs error and returns null, if it doesn't have one.
    Removed: Surplus warning logged when the lower-level connection reports a Disconnected state more than once.
    Fixed: When using the 4.x mono runtime in Unity, the Socket.Receive method could get stuck and cause timeouts (in Editor and builds). The LoadBalancingClient now works around this by using the SocketUdpAsync class from our Photon dll in those cases. Please report if there are network-issues with 4.x runtime, mono.
    Changed: Enum DisconnectCause. Replace TimeoutDisconnect with ClientTimeout. Replace DisconnectByServer with ServerTimeout. Replace DisconnectByServerUserLimit with MaxCcuReached.
    Added: Enum DisconnectCause.DisconnectByServerReasonUnknown for the case it's neither a ccu-limit, timeout nor a disconnect by the room's logic.
    Changed: Warning-dialog "AppId not set" is not shown, if the configuration points to a Master Server (Photon OnPremise). When the new server SDK expects an AppId, too, this could be reverted.
    Updated: Cockpit demo scene to expose automaticallySyncLevel and load level form. Updated links to docs.
    Updated: The readme.txt.
    Updated: The Photon3Unity3d.dll to v4.1.2.2, which has a few changes. See release_history.txt.
     
    hopeful likes this.
  49. ddalacu

    ddalacu

    Joined:
    May 13, 2014
    Posts:
    17
    So i have the following issue: i create a room(player ttl=60 secs) , i join one player('A' used to keep the room alive when player 'B' disconnects) and instantiate it's character, then another player(B the one who disconnects) and instantiate its character, when player B disconnects due to internet issues(disable adapter) i call ReconnectAndRejoin which successfully rejoins the room(so far so good each player have it s own character), now disconnect player B again and rejoins at this moment player B will have two characters, each time i disconnect player B and reconnect it the number of B characters duplicates (1,2,4,8 ...).

    The behaviour i expect is when disconnected and reconnected player B should have one character no matter how manny times i disconnect and reconnect to the same room.
    This problem can be reproduced with the demo slot racer too with a little change to OnJoinedInstantiate.cs after the prefab instantiation from the provided list make shure to null the list so it won't call instantiate every time you rejoin the room, now if you repeat the steps i sayd after each disconnect you will have 1,2,4 ... controllers
    Does anyone have any idea how to fix this??
    Video with the problem
     
    Last edited: Oct 18, 2018
  50. Sachinv2

    Sachinv2

    Joined:
    Sep 14, 2018
    Posts:
    2
    @tobiass Yes we are exporting for WebGL only