Unity.Network any plans in WebGL?

Can anyone from Unity comment on if there are any plans to support the unity networking classes in WebGL at any point? I realize even among the other platforms not all targets support Unity’s networking classes (windows phone for example) I’m just looking for a statement either way on whether or not there are any plans to do so.

Developers might want to develop a webrtc asset on the store if there are no current plans for webgl networking so I figured Id ask.

UnityEngine.Networking (which is based on RakNet) will never be supported on WebGL.

The reason is that RakNet relies on direct access to TCP/UDP Sockets which is not possible in WebGL (and will never be due to security concerns).

Unity 5.1 will (most likely) ship our upcoming new networking library UNET (which will make UnityEngine.Networking deprecated), which will support WebGL (via a WebSocket brigde) out of the box.

Other options:

-Build a wrapper for WebSockets or WebRTC yourself (examples have been posted to this forum).

-Use an existing third party library which wraps WebSockets (SmartFoxServer or Photon).

Thanks for the detailed reply Jonas!

I realize 5.1’s UNET isn’t out yet but since for WebGL it’s built on websockets it will require a relay server correct? Just want to double check that for LAN based products (like the asset in my signature) there would be no way around needing to go out to the internet and back for something on the LAN using UNET on the webgl target. Well I guess technically a server could be on the LAN but that isn’t prudent for most users of the asset.

I’m pretty sure the answer is no and it’s understandable I just wanted to verify.

Yes, it will require a relay server (which UNET will provide), so correct, it would not work for a local LAN setup without requiring setting up a UNET server. But then, if you host games on a web server to run with WebGL, an internet connection can sort of be assumed (i guess Chromebooks in offline mode might be an exception).

For direct networking between clients, you’d need to use WebRTC. gfoot on this forum posted a wrapper to do that. However, unlike WebSockets, not all browsers support WebRTC yet.

WebRTC requires exchanging a few hundred bytes each way to establish a connection, then is peer-to-peer after that. It doesn’t specify how the handshake is exchanged - usually websockets are used, but you could for example connect two mobile phones by having each take a photo of a QR code displayed on the other. That would work for a PC too if it had a webcam, but doesn’t really work as a general solution.

Is Unity planning to have a Cloud Based Networking Service like Photon? Or do we still have to host our own servers with UNet? As I understood it previously the older Unity Networking Solution did provide a Master Server I think for us to connect to, but it was not designed to be used in production, just more for testing. Is that the same idea your planning to do with UNet, just provide a test server, but we still need to host our own after?

If anyone is looking for a partner/client with a bit of funding for multiuser WebGL work in Unity, I’ve got a university related research project in need of a hand with the networking side. - sguynup@aii.edu

Check your Email.

Are there any updates regarding this topic? I just want to use components like NetworkManager or NetworkAnimators in a WebGL application. Is this possible with UNET?

Yes, this is possible. This thread is old and was referring to our old networking system. The new networking tech (NetworkManager or NetworkAnimators) should be supported, but may need some configuration to use WebSockets which enable it in WebGL. @Marco-Trivellato may be able to comment on how to set it up?

That is great. I’m always getting this error:

Failed running C:\Program Files\Unity\Editor\Data\Tools/UnusedByteCodeStripper2/UnusedBytecodeStripper2.exe -out “E:\Repositories\WebDevelopment\Unity\LOP\Temp\StagingArea\Data\Managed\tempStrip” -l none -c link -x “C:\Program Files\Unity\Editor\Data\Tools\native_link.xml” -f “C:\Program Files\Unity\Editor\Data\il2cpp\LinkerDescriptors” -x “E:\Repositories\WebDevelopment\Unity\LOP/Temp/StagingArea/Data/methods_pointedto_by_uievents.xml” -d “E:\Repositories\WebDevelopment\Unity\LOP\Temp\StagingArea\Data\Managed” -a “E:\Repositories\WebDevelopment\Unity\LOP\Temp\StagingArea\Data\Managed\Assembly-CSharp-firstpass.dll” -a “E:\Repositories\WebDevelopment\Unity\LOP\Temp\StagingArea\Data\Managed\Assembly-CSharp.dll” -a “E:\Repositories\WebDevelopment\Unity\LOP\Temp\StagingArea\Data\Managed\UnityEngine.Networking.dll”

stdout:
Fatal error in Mono CIL Linker
System.Exception: Error processing method: ‘System.Boolean UnityEngine.Networking.NetworkServer::InternalListen(System.String,System.Int32)’ in assembly: ‘UnityEngine.Networking.dll’ —> Mono.Cecil.ResolutionException: Failed to resolve System.Int32 UnityEngine.Networking.NetworkTransport::AddHost(UnityEngine.Networking.HostTopology,System.Int32,System.String)
at Mono.Linker.Steps.MarkStep.MarkMethod (Mono.Cecil.MethodReference reference) [0x00000] in :0
at Mono.Linker.Steps.MarkStep.MarkInstruction (Mono.Cecil.Cil.Instruction instruction) [0x00000] in :0
at Mono.Linker.Steps.MarkStep.MarkMethodBody (Mono.Cecil.Cil.MethodBody body) [0x00000] in :0
at Mono.Linker.Steps.MarkStep.ProcessMethod (Mono.Cecil.MethodDefinition method) [0x00000] in :0
at Mono.Linker.Steps.MarkStep.ProcessQueue () [0x00000] in :0
— End of inner exception stack trace —
at Mono.Linker.Steps.MarkStep.ProcessQueue () [0x00000] in :0
at Mono.Linker.Steps.MarkStep.Process () [0x00000] in :0
at Mono.Linker.Steps.MarkStep.Process (Mono.Linker.LinkContext context) [0x00000] in :0
at Mono.Linker.Pipeline.Process (Mono.Linker.LinkContext context) [0x00000] in :0
at Mono.Linker.Driver.Run () [0x00000] in :0
at Mono.Linker.Driver.RunDriver (Mono.Linker.Driver driver) [0x00000] in :0
stderr:

UnityEngine.Debug:LogError(Object)
UnityEditorInternal.Runner:RunManagedProgram(String, String, String, CompilerOutputParserBase) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:66)
UnityEditorInternal.AssemblyStripper:RunAssemblyLinker(IEnumerable1, String&, String&, String, String) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:192) UnityEditorInternal.AssemblyStripper:StripAssembliesTo(String, String, String&, String&, String, String, IEnumerable1) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:185)
UnityEditorInternal.AssemblyStripper:Strip(String, String, String&, String&, String, String, IEnumerable1) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:136) UnityEditorInternal.AssemblyStripper:Strip(String[ ], String[ ], String, String, String&, String&, String, String, IEnumerable1) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:121)
UnityEditorInternal.IL2CPPBuilder:RunAssemblyStripper(IEnumerable, String, String[ ], String[ ], String) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:441)
UnityEditorInternal.IL2CPPBuilder:StripAssemblies(IEnumerable1, String) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:414) UnityEditorInternal.IL2CPPBuilder:Run() (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:291) UnityEditorInternal.IL2CPPUtils:RunIl2Cpp(String, IIl2CppPlatformProvider, Action1, RuntimeClassRegistry) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:218)
UnityEditor.HostView:OnGUI()

And I thought this error occurs because Networking is not supported in WebGL. But maybe my configuration is wrong?

Thank you for your reply!

This was fixed a few patches ago. Could you please try to use Unity 5.2.2 ?

To use UNET in WebGL, you just need to enable NetworkInfo=>useWebSockets in your NetworkLobbyManager component.

Just be aware that you cannot host games on the WebGL side, you can only join existing games.

Sadly I still have problems to achieve my goal.
I have activated the “use websockets” checkbox in the NetworkManager (not the NetworkLobbyManager). And build my project for windows as standalone. Now I want to choose the “LAN Host” or “LAN Server Only” option in the default HUD. Sadly the following error message occurs:

And when I’m trying to build the WebGL application and running the index.html, I’m getting the following error in the console:

Here you can see my configuration of the NetworkManager:

  • is this with Unity 5.2.2 ?
  • could you please post the stacktrace from a Development Mode build ?

Please re-upload the image

Yes this is with Unity 5.2.2.

Stacktrace:

Furthermore I attached the image to this message.

Chances are it is the same problem reported in this other thread, which we already fixed in 5.3

Could you please try to add a dummy script with an empty OnGUI method to any of the game objects in the scene ?

Yes it works! Thanks a lot for this! Now I want my WebGL client to connect to a windows standalone server. If I enable the “use websockets” checkbox in the NetworkManager, the following error appears when I run the exe and press the “LAN Host” button:

If I disable the “use websocket” checkbox for the windows standalone, the WebGL client cannot connect to the standalone server, because he is not using websockets.

@PhilippLe
Did you find a solution ?

It works now. Here are my settings of the network manager. I wonder which option did the job …

Hi Guys!
Does somebody know how I can find and connect internet match in WebGL?
I created new topic, but no one answers.

Maybe someone can tell me, how I can find and connect internet match in WebGL(UNET) ?
Thanks in advance