Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

SignalR .Core Streaming Size Limitation (~70K Bytes)

$
0
0

Hello everybody,

we have developed an ASP.NET Core (3.1) SignalR Server. A Unity client connects to the Server and starts streaming an image to the server. The image is streamed by computing a bytes array and creating small packages. Each package contains maximal 6000 bytes. These packages are then processed by the server and sent directly to another client (see code sample on the bottom). 

When we run everything on my local machine - everything works fine. When we run the server on another machine but in the same network - everything still works. However, when we run the server in a different network, the connection between the server and the client gets lost - but only when we try to send an image bigger than ~70K Bytes. 

We already tried to change the limiation properties on the server like: 

-MaximumReceiveMessageSize 
-  StreamBufferCapacity
- ApplicationMaxBufferSize
- TransportMaxBufferSize

However, nothing worked so far. Furthermore, we also checked the ISS configuration but did not found anything. 

As Hub Protocoll we use MessagePack. Neither the server nor the client throw any kind of error message. The signalR connection gets instantly lost. Furthermore, the connection handler on the client side does not even  get informed that the state of the connection has changed.

Here is the example code we use on the client (SignalR Core with BestHTTP2): 

 public void stream(byte[] imgBytes)
    {
       int imgBufferSize = 6000;

       using (var controller = this.host3DHub.GetUpStreamController<string, string>("Stream"))
        {
            controller.OnSuccess(_ =>
            {
                Console.Log("Stream finished");
                controller.Cancel();
            });
            controller.OnError(error =>
            {
                Console.Log("Streaming failed. Error: " + error);
                controller.Cancel();
            });
            for (var i = 0; i < imgBytes.Length; i = i + imgBufferSize)
            {

                int lengthArr = (i + imgBufferSize >= imgBytes.Length) ? imgBytes.Length - i : imgBufferSize;
                byte[] imgChunk = new byte[lengthArr];
                Array.Copy(imgBytes, i, imgChunk, 0, lengthArr);
                controller.UploadParam(imgChunk);
            }
            controller.Finish();
        }
    }

The corresponding Code on the Host is: 

public async Task Streaming(IAsyncEnumerable<byte[]> stream)
{
    try{
if (connectedClients.ContainsKey(Context.ConnectionId)){ Client client = connectedClients[Context.ConnectionId]; await foreach (var item in stream) { Clients.OthersInGroup(divaNr).SendAsync("newRenderChunk", item); } } }catch(System.Exception e){ Console.Log("StreamRendering", "Error during streaming chunks. E: " + e.Message); }
}

 

If anybody can help us or give us a hint what we can test? Thanks already in advance!

Lea


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>