Search Unity

WebGL with SignalR - ArgumentNullException: Value cannot be null

Discussion in 'Multiplayer' started by akaBase, May 3, 2019.

  1. akaBase

    akaBase

    Joined:
    Aug 22, 2017
    Posts:
    35
    Hello,

    I have integrated AspeNetCore SignalR with my project and am able to connect to the Hubs in the Editor and Standalone Builds, but when I do a WebGL build it throws an exception when attempting to connect to the Hub.

    Exception is as follows:
    The last line
    suggests it's an issue with the compression Unity uses.

    I have tried using a linker xml file to make sure that everythijng is kept from the SignalR DLLs, but the exception is still thrown and nothing changes.

    Is this a known issue?

    Tested on Unity Version/s 2019.1 and 2018.3
    SignalR.Client 1.04 and 1.1.0 (tested both)
    SignalR Hub uses SignalR 1.0.4
     
  2. akaBase

    akaBase

    Joined:
    Aug 22, 2017
    Posts:
    35
    Update: I have now tested it with more platforms and devices and it is only WebGL with the issue.

    Works with the following platforms
    IOS
    Android
    Windows Standalone
    Editor
     
  3. Katori

    Katori

    Joined:
    Nov 30, 2009
    Posts:
    60
    It looks like you are attempting to use ASP.NET's client code in the WebGL client.

    This will not work. All network communication in WebGL must go through the JavaScript layer using a "JSLIB" file. With this you can initiate a WebSockets or SignalR connection using the SignalR JavaScript client and ferry data back and forth between the Unity and JS layers.

    See below how we did it with WebSockets in Mirror, I have worked with SignalR, the JavaScript client is very similar to the WebSockets API:
    https://github.com/vis2k/Mirror/blo...e/Transport/Websocket/Plugins/WebSocket.jslib
    https://github.com/vis2k/Mirror/blob/master/Assets/Mirror/Runtime/Transport/Websocket/ClientJs.cs
     
    Gauldronborn likes this.
  4. akaBase

    akaBase

    Joined:
    Aug 22, 2017
    Posts:
    35
    AspNetCore but yes I am, Thanks for the reply will look into you solution. much appreciated.
     
  5. tianci97

    tianci97

    Joined:
    Apr 22, 2019
    Posts:
    1