I'm using PUN2 in Unity 2021.1.5f to connect a multiplayer game. It's work in Android, iOS and Windows.
When I build for WebGL and try to connect with the server, the next error show up:
Connect() failed to create a IPhotonSocket instance for WebSocketSecure.SocketImplementationConfig:
{Udp=ExitGames.Client.Photon.SocketUdp, Tcp=ExitGames.Client.Photon.SocketTcp,
WebSocket=ExitGames.Client.Photon.SocketWebTcp,
WebSocketSecure=ExitGames.Client.Photon.SocketWebTcp}
Exception: System.MissingMethodException: Constructor on type
'ExitGames.Client.Photon.SocketWebTcp' not found.
at System.RuntimeType.CreateInstanceImpl (System.Reflection.BindingFlags bindingAttr,
System.Reflection.Binder binder, System.Object[] args, System.Globalization.CultureInfo culture,
System.Object[] activationAttributes, System.Threading.StackCrawlMark& stackMark)
[0x00000] in <00000000000000000000000000000000>:0
I new with PUN2 and I don't know what happens. I configured my PhotonSettings with the web socket secure protocol.
I find an answer:
There are an option in Unity who cut code for optimization the Managed Stripping Level. I changed that for Low and worked for me.
Also put this in link.xml:
<assembly fullname="PhotonWebSocket">
<type fullname="ExitGames.Client.Photon.SocketWebTcp" preserve="all"/>
</assembly>
<assembly fullname="PhotonWebSocket">
<type fullname="ExitGames.Client.Photon.SocketWebSecure" preserve="all"/>
</assembly>