Coder Social home page Coder Social logo

besthttp-issues's People

Contributors

benedicht avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

zhwebo

besthttp-issues's Issues

Update LitJson

I came across a problem, that LitJson throws an error when parsing an object that uses System.Nullable.
However, this seems to be fixed in newer versions, and manually updating the LitJson classes solved the issue for me.

Perhaps it might be worth updating them officially?

Async HTTP request fails if first one gets a cancled token.

Hey!

So what happens is that the "HTTPUpdateDelegator" does not exist if the first request is given a canceled cancelation token.

CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(); CancellationToken cancellationToken = cancellationTokenSource.Token; cancellationTokenSource.Cancel(); var response = await httpRequest.GetHTTPResponseAsync(cancellationToken);
The task never completes because it doesn't get to:
public static HTTPRequest SendRequest(HTTPRequest request) and calls
if (!IsSetupCalled)
Setup();

I fixed it now by calling Setup in:
```
[UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.AfterSceneLoad)]
static void Reset()
{
IsSetupCalled = false;
HTTPManager.Logger.Information("HTTPManager", "Reset called!");
HTTPManager.Setup();
}


im using the 2.0.5 version, I did see in release notes 2.0.6 but I cant download it yet.

HttpProxy to support url bypass

Greetings, using your asset I stumbled upon an issue that I couldn't get around easily, I've looked through the documentation provided on how to setup a proxy, I've seen that I am able to set it globally or per request, which works perfectly well.

Problem is that sometimes it would be useful to specify a list of urls that the proxy should ignore so that I can set it up more easily. Is there a way to do this? Would you consider it as an enhancement for this already great asset?

Thanks in advance

Compile Error when disabling caching [2.1.0]

When BESTHTTP_DISABLE_CACHING preprocessor is set, ConnectionHelper class is not compiled and give following error.

The type or namespace name 'LoggingContext' could not be found (are you missing a using directive or an assembly reference?)

Upload speed under iOS way slower than under macOS

First of all, I love this asset. It works very well.

However, I noticed a significant difference in upload speed on iOS compared to macOS. I am using HTTP POST to send image files to an S3 bucket. On my macOS machine (i.e. in the editor) the upload is almost instant (I restrict the image dimensions to 768 on the shorter dimension, so the files aren't that big).

On iOS, however, the same upload takes multiple seconds, even if the device is in the same WI-FI network. I am using an iPhone X, so the device speed shouldn't be a big issue.

What might cause this huge difference?

I am now working on video uploads with significant more data, so I am getting pretty worried about the speed I will be able to achieve and the resulting usability.

Implement local DNS cache

In-memory, thread safe DNS cache. It must be able to fall back seamlessly to pure system provided DNS querying.

Add OnPing/OnPong(byte[]) callbacks

We use a timestamp payload in Ping/Pong-frames to estimate server time on devices. Ping/Pong frames are regularly exchanged, small, and have no meaningful processing overhead on the server, so they seem to be a good choice for such synchronization.

Currently, this requires us to tinker with the BestHTTP sources, hence the enhancement request to add OnPing/OnPong(byte[]) callbacks.

As per RFC 6455, Section 5.5 "All control frames MUST have a payload length of 125 bytes or less and MUST NOT be fragmented.", so implementation should be very straightforward ;)

Socket.io: Internal error! Message: Non-negative number required.

I'm trying to connect to a very simple node.js chat server, running locally. But just doing this

var manager = new SocketManager( new Uri( "http://localhost:3000/" ) ); manager.Socket.On( SocketIOEventTypes.Connect, ( socket, packet, args ) => Debug.Log( "connected" ) ); // Debug.LogFormat("Connected {0}, {1}, {2}", socket, packet, args ) );

gives me this error:

{"tid":1,"div":"PollingTransport","msg":"ParseResponse","ex": [{"msg": "Non-negative number required.\r\nParameter name: count", "stack": " at System.Text.UTF8Encoding.GetString (System.Byte[] bytes, System.Int32 index, System.Int32 count) [0x0003a] in <fb001e01371b4adca20013e0ac763896>:0 \r\n at BestHTTP.SocketIO.Transports.PollingTransport.ParseResponse (BestHTTP.HTTPResponse resp) [0x00190] in F:\\PROJECTS 2020\\Mine\\Assets\\Best HTTP\\Source\\SocketIO\\Transports\\PollingTransport.cs:408 "}],"stack":" at SocketIO.Transports.PollingTransport.ParseResponse (HTTPResponse resp) [0x002b4] in F:\\PROJECTS 2020\\Mine\\Assets\\Best HTTP\\Source\\SocketIO\\Transports\\PollingTransport.cs:454 \r at SocketIO.Transports.PollingTransport.OnRequestFinished (HTTPRequest req, HTTPResponse resp) [0x0009a] in F:\\PROJECTS 2020\\Mine\\Assets\\Best HTTP\\Source\\SocketIO\\Transports\\PollingTransport.cs:187 \r at Core.RequestEventHelper.HandleRequestStateChange (Core.RequestEventInfo event) [0x001d4] in F:\\PROJECTS 2020\\Mine\\Assets\\Best HTTP\\Source\\Core\\RequestEvents.cs:313 \r at Core.RequestEventHelper.ProcessQueue () [0x002ef] in F:\\PROJECTS 2020\\Mine\\Assets\\Best HTTP\\Source\\Core\\RequestEvents.cs:221 \r at HTTPManager.OnUpdate () [0x00001] in F:\\PROJECTS 2020\\Mine\\Assets\\Best HTTP\\Source\\HTTPManager.cs:374 \r at HTTPUpdateDelegator.Update () [0x00020] in F:\\PROJECTS 2020\\Mine\\Assets\\Best HTTP\\Source\\HTTPUpdateDelegator.cs:171 ","ctxs":[],"t":637297288197788770,"ll":"Exception","bh":1} UnityEngine.Debug:LogError(Object) BestHTTP.Logger.UnityOutput:Write(Loglevels, String) (at Assets/Best HTTP/Source/Logger/UnityOutput.cs:22) BestHTTP.Logger.ThreadedLogger:WriteToOutput(LogJob) (at Assets/Best HTTP/Source/Logger/ThreadedLogger.cs:107) BestHTTP.Logger.ThreadedLogger:ThreadFunc() (at Assets/Best HTTP/Source/Logger/ThreadedLogger.cs:121) BestHTTP.PlatformSupport.Threading.<>c__DisplayClass5_0:<RunLongLiving>b__0(Object) (at Assets/Best HTTP/Source/PlatformSupport/Threading/ThreadedRunner.cs:98) System.Threading.ThreadHelper:ThreadStart(Object)

This is the chat server code:

`var app = require('express')();
var http = require('http').Server(app);
var io = require('socket.io')(http);

app.get('/', function(req, res){
res.sendFile(__dirname + '/index.html');
});

var userId = 0;
io.on('connection', function(socket){
socket.userId = userId ++;
console.log('a user connected, user id: ' + socket.userId);

socket.on('chat', function(msg){
console.log('message from user#' + socket.userId + ": " + msg);
io.emit('chat', {
id: socket.userId,
msg: msg
});
});
});

http.listen(3000, function(){
console.log('listening on *:3000');
});`

What's up with that?

Race condition in HubConnection CloseAsync

If a connection cannot be made to a remote server, CloseAsync can crash with a NullReference exception:

public Task<HubConnection> CloseAsync()
{
    if (this.closeAsyncTaskCompletionSource != null)
        throw new Exception("CloseAsync already called!");

    this.closeAsyncTaskCompletionSource = new TaskCompletionSource<HubConnection>();

    this.OnClosed += OnClosedAsyncCallback;
    this.OnError += OnClosedAsyncErrorCallback;

    // Avoid race condition by caching task prior to StartClose,
    // which asynchronously calls OnClosedAsyncCallback, which nulls
    // this.closeAsyncTaskCompletionSource immediately before we have
    // a chance to read from it.
    //
    // Old:
    // this.StartClose();
    // return this.closeAsyncTaskCompletionSource.Task;
    //
    var task = this.closeAsyncTaskCompletionSource.Task;
    this.StartClose();
    return task;
}

Exception: An unexpected error occurred during connection handshake

I am getting An unexpected error occurred during connection handshake exception when trying to connect to a signalr server.

The same server works fine when connecting via web using chrome/firefox and using the official library signalr client from a C# script. It also works fine from unity using Best HTTP when connecting to the same server run locally from visual studio.

The deployed server is proxying using apache through to a kestrel service on ubuntu.

besthttp.log

SignalR Core: InvalidDataException: Missing required property 'type'.

I found an error which I have tried to investigate and fix it for days but still stuck with it.

After the client has connected with the server for 2-5 seconds, I have got a bellowing message on the Hub_OnError event.

Connection closed with an error. InvalidDataException: Missing required property 'type'.

More info:

  • The server is .Net Core 3.1 running on IIS
  • The client is WebGL. My mainly platform is WebGL but the error also occurs on Android and Windows but I have not tried on other target platforms.
  • Error does not happen on Unity Editor.
  • Hub connected with WebSocket transport using the JSON encoder.

Please let me know if you have any clue, thank you.

SNAG-0000-20200718-174028

Error during request

Hey guys, I'm having issue with headers. It is hard to understand how this error can happen, when I create new request.
error log :
[637357846612236490] Ex [HTTP2Handler]: Sender thread - Message: 1: An item with the same key has already been added. Key: Accept-Encoding at System.Collections.Generic.Dictionary2[TKey,TValue].TryInsert (TKey key, TValue value, System.Collections.Generic.InsertionBehavior behavior) [0x000c1] in <437ba245d8404784b9fbab9b439ac908>:0 at System.Collections.Generic.Dictionary2[TKey,TValue].Add (TKey key, TValue value) [0x00000] in <437ba245d8404784b9fbab9b439ac908>:0
at BestHTTP.HTTPRequest.AddHeader (System.String name, System.String value) [0x0002f] in /Users/lordjohn/Documents/Workspace/blot2-unity/Assets/Plugins/Best HTTP/Source/HTTPRequest.cs:781
at BestHTTP.HTTPRequest.EnumerateHeaders (BestHTTP.OnHeaderEnumerationDelegate callback, System.Boolean callBeforeSendCallback) [0x000b7] in /Users/lordjohn/Documents/Workspace/blot2-unity/Assets/Plugins/Best HTTP/Source/HTTPRequest.cs:909
at BestHTTP.Connections.HTTP2.HPACKEncoder.Encode (BestHTTP.Connections.HTTP2.HTTP2Stream context, BestHTTP.HTTPRequest request, System.Collections.Generic.Queue1[T] to, System.UInt32 streamId) [0x0009d] in /Users/lordjohn/Documents/Workspace/blot2-unity/Assets/Plugins/Best HTTP/Source/Connections/HTTP2/HPACKEncoder.cs:48 at BestHTTP.Connections.HTTP2.HTTP2Stream.ProcessState (System.Collections.Generic.List1[T] outgoingFrames) [0x00060] in /Users/lordjohn/Documents/Workspace/blot2-unity/Assets/Plugins/Best HTTP/Source/Connections/HTTP2/HTTP2Stream.cs:391
at BestHTTP.Connections.HTTP2.HTTP2Stream.Process (System.Collections.Generic.List1[T] outgoingFrames) [0x00082] in /Users/lordjohn/Documents/Workspace/blot2-unity/Assets/Plugins/Best HTTP/Source/Connections/HTTP2/HTTP2Stream.cs:160 at BestHTTP.Connections.HTTP2.HTTP2Handler.RunHandler () [0x004fa] in /Users/lordjohn/Documents/Workspace/blot2-unity/Assets/Plugins/Best HTTP/Source/Connections/HTTP2/HTTP2Handler.cs:284 StackTrace: at System.Collections.Generic.Dictionary2[TKey,TValue].TryInsert (TKey key, TValue value, System.Collections.Generic.InsertionBehavior behavior) [0x000c1] in <437ba245d8404784b9fbab9b439ac908>:0
at System.Collections.Generic.Dictionary2[TKey,TValue].Add (TKey key, TValue value) [0x00000] in <437ba245d8404784b9fbab9b439ac908>:0 at BestHTTP.HTTPRequest.AddHeader (System.String name, System.String value) [0x0002f] in /Users/lordjohn/Documents/Workspace/blot2-unity/Assets/Plugins/Best HTTP/Source/HTTPRequest.cs:781 at BestHTTP.HTTPRequest.EnumerateHeaders (BestHTTP.OnHeaderEnumerationDelegate callback, System.Boolean callBeforeSendCallback) [0x000b7] in /Users/lordjohn/Documents/Workspace/blot2-unity/Assets/Plugins/Best HTTP/Source/HTTPRequest.cs:909 at BestHTTP.Connections.HTTP2.HPACKEncoder.Encode (BestHTTP.Connections.HTTP2.HTTP2Stream context, BestHTTP.HTTPRequest request, System.Collections.Generic.Queue1[T] to, System.UInt32 streamId) [0x0009d] in /Users/lordjohn/Documents/Workspace/blot2-unity/Assets/Plugins/Best HTTP/Source/Connections/HTTP2/HPACKEncoder.cs:48
at BestHTTP.Connections.HTTP2.HTTP2Stream.ProcessState (System.Collections.Generic.List1[T] outgoingFrames) [0x00060] in /Users/lordjohn/Documents/Workspace/blot2-unity/Assets/Plugins/Best HTTP/Source/Connections/HTTP2/HTTP2Stream.cs:391 at BestHTTP.Connections.HTTP2.HTTP2Stream.Process (System.Collections.Generic.List1[T] outgoingFrames) [0x00082] in /Users/lordjohn/Documents/Workspace/blot2-unity/Assets/Plugins/Best HTTP/Source/Connections/HTTP2/HTTP2Stream.cs:160
at BestHTTP.Connections.HTTP2.HTTP2Handler.RunHandler () [0x004fa] in /Users/lordjohn/Documents/Workspace/blot2-unity/Assets/Plugins/Best HTTP/Source/Connections/HTTP2/HTTP2Handler.cs:284
UnityEngine.Debug:LogError(Object)
BestHTTP.Logger.DefaultLogger:Exception(String, String, Exception) (at Assets/Plugins/Best HTTP/Source/Logger/DefaultLogger.cs:111)
BestHTTP.Connections.HTTP2.HTTP2Handler:RunHandler() (at Assets/Plugins/Best HTTP/Source/Connections/HTTP2/HTTP2Handler.cs:402)
BestHTTP.Connections.HTTPConnection:ThreadFunc() (at Assets/Plugins/Best HTTP/Source/Connections/HTTPConnection.cs:117)
BestHTTP.PlatformSupport.Threading.<>c__DisplayClass4_0:b__0() (at Assets/Plugins/Best HTTP/Source/PlatformSupport/Threading/ThreadedRunner.cs:79)
System.Threading.ThreadHelper:ThreadStart(Object)

WebSockets: Question on error behaviour

Hi Benedicht,

I have a question on how BestHTTP/2 handles WebSockets connections. We are using it on mobile devices which have to react on network changes quickly, e.g. if the user walks into an area where the connection to a WIFI is lost and connection switches to LTE or vice versa.

We have noticed that BestHTTP/2 not always fires OnClosed or OnError in this case, but we were able to work-around this by activating pings. However, we've noticed two interesting things here:

  1. According to the docs, the pings should be sent every 100ms per default. However, OnError is fired only after 10s or so, which is way longer. Why is this the case?

  2. If OnError is fired in these cases, IsOpen is false, which we interpret as the WebSocket as being closed. We see that once the connection picks up again, no further messages can be sent through the socket, so we guess that this assumption is true. However, OnClose is not fired, which makes our own business logic believe that the socket is still open. We worked around this by checking if IsOpen is false, and calling our OnClose handler in this case, but this is pretty ugly, and we're unsure if this might lead to unwanted side-effects. Is there a reason why OnClose is not fired in this case?

  3. The errors reported by OnError only contain a (pretty long) human-friendly text string, but not an error code. To handle them, it would be great to a) be able to use a code instead and b) know which of these error codes might happen. We tried to find this out by trial-and-error.

HTTP POST breaks if connected to a local machine and app goes into background

First off, I just noticed that POST uploads initiated on a mobile app are actually continued if the app ist sent to the background. This is just amazing, I wouldn't have expected that!

I've noticed one issue, however: In my app, I am using a mix of WebSockets to establish a connection to my own server, plus HTTP POST to communicate with AWS S3.

The workflow is as follows:

  1. Use the WebSocket connection to request a signed POST Request from my server, that can then be used for S3 uploads
  2. POST the upload to S3

Now I put the app into the background while step 2 is still in progress. This works fine if my server is located on an EC2 instance. Once I bring the app to the foreground, the upload is finished. Great.

If I do the same, however, in a scenario where my own server runs locally on my Mac (and my iPhone connects to it via WiFi and WebSockets), the POST connection to S3 breaks once I put the app to the background. Once I put it in the foreground again, I can see the Exception below in the app logs. The strange thing is: Even in this scenario, S3 is still the upload target (albeit another bucket). That means: the only difference is that the WebSockets connection goes to another server (which should not affect the independent POST connection).

Do you have any idea how this difference can be explained?

Here's the exception I get:

[637305134864991490] D [HTTP1Handler]: 1: One or more errors occurred.   at System.Threading.Tasks.Task.ThrowIfExceptional (System.Boolean includeTaskCanceledExceptions) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.Wait (System.Int32 millisecondsTimeout, System.Threading.CancellationToken cancellationToken) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.Wait () [0x00000] in <00000000000000000000000000000000>:0 
  at Mono.Net.Security.MobileAuthenticatedStream.Write (System.Byte[] buffer, System.Int32 offset, System.Int32 count) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Net.Security.SslStream.Write (System.Byte[] buffer, System.Int32 offset, System.Int32 count) [0x00000] in <00000000000000000000000000000000>:0 
  at BestHTTP.Extensions.WriteOnlyBufferedStream.Flush () [0x00000] in <00000000000000000000000000000000>:0 
  at BestHTTP.HTTPRequest.SendOutTo (System.IO.Stream stream) [0x00000] in <00000000000000000000000000000000>:0 
  at BestHTTP.Connections.HTTP1Handler.RunHandler () [0x00000] in <00000000000000000000000000000000>:0 
  at BestHTTP.Connections.HTTPConnection.ThreadFunc () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Action.Invoke () [0x00000] in <00000000000000000000000000000000>:0 
  at BestHTTP.PlatformSupport.Threading.ThreadedRunner+<>c__DisplayClass4_0.<RunLongLiving>b__0 (System.Object param) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.ParameterizedThreadStart.Invoke (System.Object obj) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.ThreadHelper.ThreadStart_Context (System.Object state) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.ContextCallback.Invoke (System.Object state) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.ThreadHelper.ThreadStart (System.Object obj) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.ParameterizedThreadStart.Invoke (System.Object obj) [0x00000] in <00000000000000000000000000000000>:0 
2: Unable to write data to the transport connection: The socket has been shut down.   at System.Net.Sockets.NetworkStream.Write (System.Byte[] buffer, System.Int32 offset, System.Int32 size) [0x00000] in <00000000000000000000000000000000>:0 
  at Mono.Net.Security.MobileAuthenticatedStream.<InnerWrite>b__67_0 () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Action.Invoke () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.InnerInvoke () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.Execute () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.ExecutionContextCallback (System.Object obj) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.ContextCallback.Invoke (System.Object state) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.ExecuteWithThreadLocal (System.Threading.Tasks.Task& currentTaskSlot) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.ExecuteEntry (System.Boolean bPreventDoubleExecution) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.ThreadPoolWorkQueue.Dispatch () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback () [0x00000] in <00000000000000000000000000000000>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.OnCompletedInternal (System.Threading.Tasks.Task task, System.Action continuation, System.Boolean continueOnCapturedContext, System.Boolean flowExecutionContext) [0x00000] in <00000000000000000000000000000000>:0 
  at Mono.Net.Security.MobileAuthenticatedStream+<>c__DisplayClass66_0.<InnerRead>b__0 () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.AsyncMethodBuilderCore+MoveNextRunner.InvokeMoveNext (System.Object stateMachine) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.ContextCallback.Invoke (System.Object state) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.AsyncMethodBuilderCore+MoveNextRunner.Run () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Action.Invoke () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.AwaitTaskContinuation.RunOrScheduleAction (System.Action action, System.Boolean allowInlining, System.Threading.Tasks.Task& currentTask) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.FinishContinuations () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.FinishStageThree () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.FinishStageTwo () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.Finish (System.Boolean bUserDelegateExecuted) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.ExecuteWithThreadLocal (System.Threading.Tasks.Task& currentTaskSlot) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.ExecuteEntry (System.Boolean bPreventDoubleExecution) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.ThreadPoolWorkQueue.Dispatch () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback () [0x00000] in <00000000000000000000000000000000>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.OnCompletedInternal (System.Threading.Tasks.Task task, System.Action continuation, System.Boolean continueOnCapturedContext, System.Boolean flowExecutionContext) [0x00000] in <00000000000000000000000000000000>:0 
  at Mono.Net.Security.MobileAuthenticatedStream.InnerRead (System.Boolean sync, System.Int32 requestedSize, System.Threading.CancellationToken cancellationToken) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.AsyncMethodBuilderCore+MoveNextRunner.InvokeMoveNext (System.Object stateMachine) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.ContextCallback.Invoke (System.Object state) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.AsyncMethodBuilderCore+MoveNextRunner.Run () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Action.Invoke () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.AwaitTaskContinuation.RunOrScheduleAction (System.Action action, System.Boolean allowInlining, System.Threading.Tasks.Task& currentTask) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.FinishContinuations () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.FinishStageThree () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.FinishStageTwo () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.Finish (System.Boolean bUserDelegateExecuted) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task`1[TResult].TrySetException (System.Object exceptionObject) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[TResult].Create () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Create () [0x00000] in <00000000000000000000000000000000>:0 
  at Mono.Net.Security.MobileAuthenticatedStream+<>c__DisplayClass66_0.<InnerRead>b__0 () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.AsyncMethodBuilderCore+MoveNextRunner.InvokeMoveNext (System.Object stateMachine) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.ContextCallback.Invoke (System.Object state) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.AsyncMethodBuilderCore+MoveNextRunner.Run () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Action.Invoke () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.AwaitTaskContinuation.RunOrScheduleAction (System.Action action, System.Boolean allowInlining, System.Threading.Tasks.Task& currentTask) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.FinishContinuations () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.FinishStageThree () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.FinishStageTwo () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.Finish (System.Boolean bUserDelegateExecuted) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.ExecuteWithThreadLocal (System.Threading.Tasks.Task& currentTaskSlot) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.ExecuteEntry (System.Boolean bPreventDoubleExecution) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.ThreadPoolWorkQueue.Dispatch () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback () [0x00000] in <00000000000000000000000000000000>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.OnCompletedInternal (System.Threading.Tasks.Task task, System.Action continuation, System.Boolean continueOnCapturedContext, System.Boolean flowExecutionContext) [0x00000] in <00000000000000000000000000000000>:0 
  at Mono.Net.Security.MobileAuthenticatedStream.InnerWrite (System.Boolean sync, System.Threading.CancellationToken cancellationToken) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.AsyncMethodBuilderCore+MoveNextRunner.InvokeMoveNext (System.Object stateMachine) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.ContextCallback.Invoke (System.Object state) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.AsyncMethodBuilderCore+MoveNextRunner.Run () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Action.Invoke () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.AwaitTaskContinuation.RunOrScheduleAction (System.Action action, System.Boolean allowInlining, System.Threading.Tasks.Task& currentTask) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.FinishContinuations () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.FinishStageThree () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.FinishStageTwo () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.Finish (System.Boolean bUserDelegateExecuted) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task`1[TResult].TrySetException (System.Object exceptionObject) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[TResult].Create () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Create () [0x00000] in <00000000000000000000000000000000>:0 
  at Mono.Net.Security.MobileAuthenticatedStream.InnerRead (System.Boolean sync, System.Int32 requestedSize, System.Threading.CancellationToken cancellationToken) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.AsyncMethodBuilderCore+MoveNextRunner.InvokeMoveNext (System.Object stateMachine) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.ContextCallback.Invoke (System.Object state) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.AsyncMethodBuilderCore+MoveNextRunner.Run () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Action.Invoke () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.AwaitTaskContinuation.RunOrScheduleAction (System.Action action, System.Boolean allowInlining, System.Threading.Tasks.Task& currentTask) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.FinishContinuations () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.FinishStageThree () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.FinishStageTwo () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.Finish (System.Boolean bUserDelegateExecuted) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task`1[TResult].TrySetException (System.Object exceptionObject) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[TResult].Create () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Create () [0x00000] in <00000000000000000000000000000000>:0 
  at Mono.Net.Security.MobileAuthenticatedStream+<>c__DisplayClass66_0.<InnerRead>b__0 () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.AsyncMethodBuilderCore+MoveNextRunner.InvokeMoveNext (System.Object stateMachine) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.ContextCallback.Invoke (System.Object state) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.AsyncMethodBuilderCore+MoveNextRunner.Run () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Action.Invoke () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.AwaitTaskContinuation.RunOrScheduleAction (System.Action action, System.Boolean allowInlining, System.Threading.Tasks.Task& currentTask) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.FinishContinuations () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.FinishStageThree () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.FinishStageTwo () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.Finish (System.Boolean bUserDelegateExecuted) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.ExecuteWithThreadLocal (System.Threading.Tasks.Task& currentTaskSlot) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.ExecuteEntry (System.Boolean bPreventDoubleExecution) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.ThreadPoolWorkQueue.Dispatch () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback () [0x00000] in <00000000000000000000000000000000>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <00000000000000000000000000000000>:0 
  at Mono.Net.Security.MobileAuthenticatedStream+<>c__DisplayClass66_0.<InnerRead>b__0 () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.AsyncMethodBuilderCore+MoveNextRunner.InvokeMoveNext (System.Object stateMachine) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.ContextCallback.Invoke (System.Object state) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.AsyncMethodBuilderCore+MoveNextRunner.Run () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Action.Invoke () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.AwaitTaskContinuation.RunOrScheduleAction (System.Action action, System.Boolean allowInlining, System.Threading.Tasks.Task& currentTask) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.FinishContinuations () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.FinishStageThree () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task`1[TResult].TrySetResult (TResult result) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[TResult].Create () [0x00000] in <00000000000000000000000000000000>:0 
  at Mono.Net.Security.MobileAuthenticatedStream.InnerWrite (System.Boolean sync, System.Threading.CancellationToken cancellationToken) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.AsyncMethodBuilderCore+MoveNextRunner.InvokeMoveNext (System.Object stateMachine) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.ContextCallback.Invoke (System.Object state) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.AsyncMethodBuilderCore+MoveNextRunner.Run () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Action.Invoke () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.AwaitTaskContinuation.RunOrScheduleAction (System.Action action, System.Boolean allowInlining, System.Threading.Tasks.Task& currentTask) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.FinishContinuations () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.FinishStageThree () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.FinishStageTwo () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.Finish (System.Boolean bUserDelegateExecuted) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task`1[TResult].TrySetException (System.Object exceptionObject) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[TResult].Create () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Create () [0x00000] in <00000000000000000000000000000000>:0 
  at Mono.Net.Security.MobileAuthenticatedStream.InnerRead (System.Boolean sync, System.Int32 requestedSize, System.Threading.CancellationToken cancellationToken) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.AsyncMethodBuilderCore+MoveNextRunner.InvokeMoveNext (System.Object stateMachine) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.ContextCallback.Invoke (System.Object state) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.AsyncMethodBuilderCore+MoveNextRunner.Run () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Action.Invoke () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.AwaitTaskContinuation.RunOrScheduleAction (System.Action action, System.Boolean allowInlining, System.Threading.Tasks.Task& currentTask) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.FinishContinuations () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.FinishStageThree () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.FinishStageTwo () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.Finish (System.Boolean bUserDelegateExecuted) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task`1[TResult].TrySetException (System.Object exceptionObject) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[TResult].Create () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Create () [0x00000] in <00000000000000000000000000000000>:0 
  at Mono.Net.Security.MobileAuthenticatedStream+<>c__DisplayClass66_0.<InnerRead>b__0 () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.AsyncMethodBuilderCore+MoveNextRunner.InvokeMoveNext (System.Object stateMachine) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.ContextCallback.Invoke (System.Object state) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.AsyncMethodBuilderCore+MoveNextRunner.Run () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Action.Invoke () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.AwaitTaskContinuation.RunOrScheduleAction (System.Action action, System.Boolean allowInlining, System.Threading.Tasks.Task& currentTask) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.FinishContinuations () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.FinishStageThree () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.FinishStageTwo () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.Finish (System.Boolean bUserDelegateExecuted) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.ExecuteWithThreadLocal (System.Threading.Tasks.Task& currentTaskSlot) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.ExecuteEntry (System.Boolean bPreventDoubleExecution) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.ThreadPoolWorkQueue.Dispatch () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback () [0x00000] in <00000000000000000000000000000000>:0 
3: The socket has been shut down   at System.Net.Sockets.Socket.Send (System.Byte[] buffer, System.Int32 offset, System.Int32 size, System.Net.Sockets.SocketFlags socketFlags) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Net.Sockets.NetworkStream.Write (System.Byte[] buffer, System.Int32 offset, System.Int32 size) [0x00000] in <00000000000000000000000000000000>:0 
  at Mono.Net.Security.MobileAuthenticatedStream.<InnerWrite>b__67_0 () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Action.Invoke () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.InnerInvoke () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.Execute () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.ExecutionContextCallback (System.Object obj) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.ContextCallback.Invoke (System.Object state) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.ExecuteWithThreadLocal (System.Threading.Tasks.Task& currentTaskSlot) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.ExecuteEntry (System.Boolean bPreventDoubleExecution) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.ThreadPoolWorkQueue.Dispatch () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback () [0x00000] in <00000000000000000000000000000000>:0 
UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
UnityEngine.Logger:Log(LogType, Object)
UnityEngine.Debug:Log(Object)
BestHTTP.Logger.DefaultLogger:Verbose(String, String)
BestHTTP.Connections.HTTP1Handler:RunHandler()
BestHTTP.Connections.HTTPConnection:ThreadFunc()
System.Action:Invoke()
BestHTTP.PlatformSupport.Threading.<>c__DisplayClass4_0:<RunLongLiving>b__0(Object)
System.Threading.ParameterizedThreadStart:Invoke(Object)
System.Threading.ThreadHelper:ThreadStart_Context(Object)
System.Threading.ContextCallback:Invoke(Object)
System.Threading.ExecutionContext:RunInternal(ExecutionContext, ContextCallback, Object, Boolean)
System.Threading.ExecutionContext:Run(ExecutionContext, ContextCallback, Object, Boolean)
System.Threading.ExecutionContext:Run(ExecutionContext, ContextCallback, Object)
System.Threading.ThreadHelper:ThreadStart(Object)
System.Threading.ParameterizedThreadStart:Invoke(Object)
 
(Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)

-> applicationDidBecomeActive()
[637305134869916970] I [RequestEventHelper]: Processing request event: [RequestEventInfo SourceRequest: https://marble-media-dev.s3-us-west-1.amazonaws.com/, Event: UploadProgress, State: Initial, Progress: 86016, ProgressLength: 1010062, Data: 0]
UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
UnityEngine.Logger:Log(LogType, Object)
UnityEngine.Debug:Log(Object)
BestHTTP.Logger.DefaultLogger:Information(String, String)
BestHTTP.Core.RequestEventHelper:ProcessQueue()
BestHTTP.HTTPManager:OnUpdate()
BestHTTP.HTTPUpdateDelegator:Update()

UploadStream problem

Hi,

I am having some problem when using UploadStream.
When I try to upload around 100MB of data, the request.Exception property gives "Unable to write data to the transport connection: The socket has been shut down.". On the other hand, on the server side I get "An existing connection was forcibly closed by the remote host".
I think that the error is not related to the amount of data but rather the time needed to upload something.
What would be the best way to find the cause of the problem?
Thanks.

Ability to reset State in HubConnection.ConnectAsync()

Currently, there is no way to reset State when connecting. This is not ideal as it means we have to initialize a new HubConnection instance every time we connect and then bind to new handlers. This becomes prevalent when attempting initial connection retries in a loop.

I think default parameter here could be useful like:

public Task<HubConnection> ConnectAsync(bool resetState = false) {
            if (resetState)
                this.State = ConnectionStates.Initial;
                
           ...

SignalrCore - OnMessage return false discards all queued messages

The docs for HubConnection say:

OnMessage: This event is called for every server-sent message. When returns false, no further processing of the message is done by the plugin.

However, the code (consolidated for clarity) looks like this:

for (int messageIdx = 0; messageIdx < messages.Count; ++messageIdx) {
    var message = messages[messageIdx];
    if (this.OnMessage != null && !this.OnMessage(this, message))
        return;  <--

I think that return should really be a continue? Otherwise any other messages in the list will be ignored as the array is cleared before calling this function.

Support for negotiation handshake for Azure Functions using Azure SignalR Service

To connect to Azure SignalR Service with a Azure Functions backend, a client must complete a successful connection negotiation.
SignalR client SDKs already contain the logic required to perform the negotiation handshake. The following is in JavaScript.

const connection = new signalR.HubConnectionBuilder()
.withUrl('https://my-signalr-function-app.azurewebsites.net/api')
.build()

Read more about the concept here:
https://docs.microsoft.com/en-us/azure/azure-signalr/signalr-concept-serverless-development-config

How can I do this in BestHTTP?
If it is not possible it would be awesome it it could be added in a future release.
Thanks!

Issue when send repeatedly with MessagePack

Hi.
I made a simple project using MessagePack encoder. I send a message (at moment a json string just for instantiating a new game object) to server receiving as response the same string.
Everything works fine but when I send (and receive) repeatedly messages randomly the following error message is thrown which I never received using Json encoder. Could it be related with client StreamBufferCapacity ?

{"tid":1,"div":"HubConnection","msg":"OnMessages - Invocation - Invoke","ex": [{"msg": "JSON parse error: Missing a comma or ']' after an array element.", "stack": " at (wrapper managed-to-native) UnityEngine.JsonUtility.FromJsonInternal(string,object,System.Type)\r\n at UnityEngine.JsonUtility.FromJson (System.String json, System.Type type) [0x0005c] in <1386288601af43018501cce2912f52f4>:0 \r\n at UnityEngine.JsonUtility.FromJson[T] (System.String json) [0x00001] in <1386288601af43018501cce2912f52f4>:0 \r\n at WebImClient.MakeStreamedGameObject (System.String json) [0x00023] in C:\Users\bnati\source\WebIM_Dev\Unity\Tests\Test2019\Assets\Scripts\SignalR\WebImClient.cs:192 \r\n at WebImClient.b__9_1 (System.String user, System.String json) [0x00000] in C:\Users\bnati\source\WebIM_Dev\Unity\Tests\Test2019\Assets\Scripts\SignalR\WebImClient.cs:84 \r\n at BestHTTP.SignalRCore.HubConnection+<>c__DisplayClass104_02[T1,T2].<On>b__0 (System.Object[] args) [0x00000] in C:\\Users\\bnati\\source\\WebIM_Dev\\Unity\\Tests\\Test2019\\Assets\\Plugins\\Best HTTP\\Source\\SignalRCore\\HubConnection.cs:822 \r\n at BestHTTP.SignalRCore.HubConnection.OnMessages (System.Collections.Generic.List1[T] messages) [0x00121] in C:\Users\bnati\source\WebIM_Dev\Unity\Tests\Test2019\Assets\Plugins\Best HTTP\Source\SignalRCore\HubConnection.cs:913 "}],"stack":" at SignalRCore.HubConnection.OnMessages (System.Collections.Generic.List`1[T] messages) [0x00136] in C:\Users\bnati\source\WebIM_Dev\Unity\Tests\Test2019\Assets\Plugins\Best HTTP\Source\SignalRCore\HubConnection.cs:917 \r at SignalRCore.Transports.WebSocketTransport.OnBinary (WebSocket.WebSocket webSocket, System.Byte[] data) [0x00067] in C:\Users\bnati\source\WebIM_Dev\Unity\Tests\Test2019\Assets\Plugins\Best HTTP\Source\SignalRCore\Transports\WebsocketTransport.cs:148 \r at WebSocket.WebSocket.b__47_1 (WebSocket.WebSocketResponse ws, System.Byte[] bin) [0x0000e] in C:\Users\bnati\source\WebIM_Dev\Unity\Tests\Test2019\Assets\Plugins\Best HTTP\Source\WebSocket\WebSocket.cs:436 \r at WebSocket.WebSocketResponse.Core.IProtocol.HandleEvents () [0x000f7] in C:\Users\bnati\source\WebIM_Dev\Unity\Tests\Test2019\Assets\Plugins\Best HTTP\Source\WebSocket\WebSocketResponse.cs:543 \r at Core.ProtocolEventHelper.ProcessQueue () [0x00087] in C:\Users\bnati\source\WebIM_Dev\Unity\Tests\Test2019\Assets\Plugins\Best HTTP\Source\Core\ProtocolEvents.cs:69 \r at HTTPManager.OnUpdate () [0x0000d] in C:\Users\bnati\source\WebIM_Dev\Unity\Tests\Test2019\Assets\Plugins\Best HTTP\Source\HTTPManager.cs:376 \r at HTTPUpdateDelegator.Update () [0x00020] in C:\Users\bnati\source\WebIM_Dev\Unity\Tests\Test2019\Assets\Plugins\Best HTTP\Source\HTTPUpdateDelegator.cs:171 ","ctxs":[{"TypeName": "HubConnection", "Hash": -366247680}],"t":637312195290775109,"ll":"Exception","bh":1}
UnityEngine.Debug:LogError(Object)
BestHTTP.Logger.UnityOutput:Write(Loglevels, String) (at Assets/Plugins/Best HTTP/Source/Logger/UnityOutput.cs:22)
BestHTTP.Logger.ThreadedLogger:WriteToOutput(LogJob) (at Assets/Plugins/Best HTTP/Source/Logger/ThreadedLogger.cs:107)
BestHTTP.Logger.ThreadedLogger:ThreadFunc() (at Assets/Plugins/Best HTTP/Source/Logger/ThreadedLogger.cs:121)
BestHTTP.PlatformSupport.Threading.<>c__DisplayClass5_0:b__0(Object) (at Assets/Plugins/Best HTTP/Source/PlatformSupport/Threading/ThreadedRunner.cs:98)
System.Threading.ThreadHelper:ThreadStart(Object)

Upload to S3 stalls for large files

I've implemented an upload to an S3 bucket, which works fine in general. But when I tried to upload larger files, the upload stalls after a while. For a 50 MB file, the stall starts at approx 38% and then eventually times out. What might be the reason for this?

Docs out of date - can't use SignalRCore

In order to instantiate a SignalRCore HubConnection I need to provide an IEncoder. The documentation references a few concrete implementations (JsonDotNetEncoder, LitJsonEncoder, MessagePackEncoder) - however, none of these encoders can be found in the downloaded code. Furthermore, the IEncoder interface changed to using a BufferSegment, but this is not described in the documentation anywhere, so custom implementations cannot be made. In conclusion, SignalRCore in latest is unusable (2.1.0).

Could these concrete implementations be added back to the source and can the documentation be updated?

(Just paid for BestHTTP/2 for the SignalRCore code - I only add this because the Asset Store lists this page as the support link...)

Errors when receiving messages from Azure SignalR

Hello,

Azure SignalR sends messages to my Unity client but they do not appear.

With BestHTTP verbose logging enabled, I get these errors in the Console:

[637259963867972886] Ex [HubConnection]: OnMessages - Invocation - GetRealArguments - Message: 1: argType.Length(2) < arguments.length(1) at BestHTTP.SignalRCore.JsonProtocol.GetRealArguments (System.Type[] argTypes, System.Object[] arguments) [0x00020] in C:\Users\dmlod\Dropbox\Invisible Hand\IhUnityClient\Invisible Hand\Assets\Best HTTP\Source\SignalRCore\JsonProtocol.cs:189
at BestHTTP.SignalRCore.HubConnection.OnMessages (System.Collections.Generic.List1[T] messages) [0x000ca] in C:\Users\dmlod\Dropbox\Invisible Hand\IhUnityClient\Invisible Hand\Assets\Best HTTP\Source\SignalRCore\HubConnection.cs:859 StackTrace: at BestHTTP.SignalRCore.JsonProtocol.GetRealArguments (System.Type[] argTypes, System.Object[] arguments) [0x00020] in C:\Users\dmlod\Dropbox\Invisible Hand\IhUnityClient\Invisible Hand\Assets\Best HTTP\Source\SignalRCore\JsonProtocol.cs:189 at BestHTTP.SignalRCore.HubConnection.OnMessages (System.Collections.Generic.List1[T] messages) [0x000ca] in C:\Users\dmlod\Dropbox\Invisible Hand\IhUnityClient\Invisible Hand\Assets\Best HTTP\Source\SignalRCore\HubConnection.cs:859
UnityEngine.DebugLogHandler:Internal_Log(LogType, LogOption, String, Object)
UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
UnityEngine.Logger:Log(LogType, Object)
UnityEngine.Debug:LogError(Object)
BestHTTP.Logger.DefaultLogger:Exception(String, String, Exception) (at Assets\Best HTTP\Source\Logger\DefaultLogger.cs:111)
BestHTTP.SignalRCore.HubConnection:OnMessages(List`1) (at Assets\Best HTTP\Source\SignalRCore\HubConnection.cs:863)
BestHTTP.SignalRCore.Transports.WebSocketTransport:OnMessage(WebSocket, String) (at Assets\Best HTTP\Source\SignalRCore\Transports\WebsocketTransport.cs:107)
BestHTTP.WebSocket.WebSocket:b__43_0(WebSocketResponse, String) (at Assets\Best HTTP\Source\WebSocket\WebSocket.cs:423)
BestHTTP.WebSocket.WebSocketResponse:BestHTTP.Core.IProtocol.HandleEvents() (at Assets\Best HTTP\Source\WebSocket\WebSocketResponse.cs:541)
BestHTTP.Core.ProtocolEventHelper:ProcessQueue() (at Assets\Best HTTP\Source\Core\ProtocolEvents.cs:69)
BestHTTP.HTTPManager:OnUpdate() (at Assets\Best HTTP\Source\HTTPManager.cs:371)
BestHTTP.HTTPUpdateDelegator:Update() (at Assets\Best HTTP\Source\HTTPUpdateDelegator.cs:165)

(Filename: Assets/Best HTTP/Source/Logger/DefaultLogger.cs Line: 111)

[637259963868022769] Ex [HubConnection]: OnMessages - Invocation - Invoke - Message: 1: Object reference not set to an instance of an object at BestHTTP.SignalRCore.HubConnection+<>c__DisplayClass98_02[T1,T2].<On>b__0 (System.Object[] args) [0x00000] in C:\Users\dmlod\Dropbox\Invisible Hand\IhUnityClient\Invisible Hand\Assets\Best HTTP\Source\SignalRCore\HubConnection.cs:778 at BestHTTP.SignalRCore.HubConnection.OnMessages (System.Collections.Generic.List1[T] messages) [0x00106] in C:\Users\dmlod\Dropbox\Invisible Hand\IhUnityClient\Invisible Hand\Assets\Best HTTP\Source\SignalRCore\HubConnection.cs:868 StackTrace: at BestHTTP.SignalRCore.HubConnection+<>c__DisplayClass98_02[T1,T2].<On>b__0 (System.Object[] args) [0x00000] in C:\Users\dmlod\Dropbox\Invisible Hand\IhUnityClient\Invisible Hand\Assets\Best HTTP\Source\SignalRCore\HubConnection.cs:778 at BestHTTP.SignalRCore.HubConnection.OnMessages (System.Collections.Generic.List1[T] messages) [0x00106] in C:\Users\dmlod\Dropbox\Invisible Hand\IhUnityClient\Invisible Hand\Assets\Best HTTP\Source\SignalRCore\HubConnection.cs:868
UnityEngine.DebugLogHandler:Internal_Log(LogType, LogOption, String, Object)
UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
UnityEngine.Logger:Log(LogType, Object)
UnityEngine.Debug:LogError(Object)
BestHTTP.Logger.DefaultLogger:Exception(String, String, Exception) (at Assets\Best HTTP\Source\Logger\DefaultLogger.cs:111)
BestHTTP.SignalRCore.HubConnection:OnMessages(List`1) (at Assets\Best HTTP\Source\SignalRCore\HubConnection.cs:872)
BestHTTP.SignalRCore.Transports.WebSocketTransport:OnMessage(WebSocket, String) (at Assets\Best HTTP\Source\SignalRCore\Transports\WebsocketTransport.cs:107)
BestHTTP.WebSocket.WebSocket:b__43_0(WebSocketResponse, String) (at Assets\Best HTTP\Source\WebSocket\WebSocket.cs:423)
BestHTTP.WebSocket.WebSocketResponse:BestHTTP.Core.IProtocol.HandleEvents() (at Assets\Best HTTP\Source\WebSocket\WebSocketResponse.cs:541)
BestHTTP.Core.ProtocolEventHelper:ProcessQueue() (at Assets\Best HTTP\Source\Core\ProtocolEvents.cs:69)
BestHTTP.HTTPManager:OnUpdate() (at Assets\Best HTTP\Source\HTTPManager.cs:371)
BestHTTP.HTTPUpdateDelegator:Update() (at Assets\Best HTTP\Source\HTTPUpdateDelegator.cs:165)

I've attached the full verbose log below for your review.

Cheers,

Dan

MsgPackProtocol fails to serialize large messages

I'm using Best HTTP/2 2.0.5 and the Json & MessagePack asset available on the Unity Asset store, and I'm getting an error when trying to send a message that serializes to larger than 256 bytes.

Here's the callstack:

[637199516832446533] Ex [HubConnection]: SendMessage - Message: 1: Cannot expand this MemoryStream
  at BestHTTP.Extensions.BufferPoolMemoryStream.set_Capacity (System.Int32 value) [0x00027] in C:\project\Assets\External\Best HTTP\Source\Extensions\BufferPoolMemoryStream.cs:175 
  at BestHTTP.Extensions.BufferPoolMemoryStream.Expand (System.Int32 newSize) [0x0000e] in C:\project\Assets\External\Best HTTP\Source\Extensions\BufferPoolMemoryStream.cs:350 
  at BestHTTP.Extensions.BufferPoolMemoryStream.Write (System.Byte[] buffer, System.Int32 offset, System.Int32 count) [0x0007a] in C:\project\Assets\External\Best HTTP\Source\Extensions\BufferPoolMemoryStream.cs:434 
  at GameDevWare.Serialization.MessagePack.MsgPackWriter.Write (System.String value) [0x0016a] in C:\project\Assets\Plugins\GameDevWare.Serialization\MessagePack\MsgPackWriter.cs:100 
  at GameDevWare.Serialization.JsonWriterExtentions.WriteString (GameDevWare.Serialization.IJsonWriter writer, System.String literal) [0x00025] in C:\project\Assets\Plugins\GameDevWare.Serialization\JsonWriterExtentions.cs:262 
  at GameDevWare.Serialization.Serializers.PrimitiveSerializer.Serialize (GameDevWare.Serialization.IJsonWriter writer, System.Object value) [0x0018c] in C:\project\Assets\Plugins\GameDevWare.Serialization\Serializers\PrimitiveTypeSerializer.cs:159 
  at GameDevWare.Serialization.JsonWriterExtentions.WriteValue (GameDevWare.Serialization.IJsonWriter writer, System.Object value, System.Type valueType) [0x0003a] in C:\project\Assets\Plugins\GameDevWare.Serialization\JsonWriterExtentions.cs:281 
  at GameDevWare.Serialization.Serializers.ObjectSerializer.Serialize (GameDevWare.Serialization.IJsonWriter writer, System.Object value) [0x000b3] in C:\project\Assets\Plugins\GameDevWare.Serialization\Serializers\ObjectSerializer.cs:112 
  at GameDevWare.Serialization.JsonWriterExtentions.WriteValue (GameDevWare.Serialization.IJsonWriter writer, System.Object value, System.Type valueType) [0x0003a] in C:\project\Assets\Plugins\GameDevWare.Serialization\JsonWriterExtentions.cs:281 
  at BestHTTP.SignalRCore.Encoders.MessagePackProtocol.WriteValue (GameDevWare.Serialization.MessagePack.MsgPackWriter writer, System.Object value) [0x00012] in C:\project\Assets\External\Best HTTP\Examples\SignalRCore\Encoders\MessagePackProtocol.cs:227 
  at BestHTTP.SignalRCore.Encoders.MessagePackProtocol.EncodeMessage (BestHTTP.SignalRCore.Messages.Message message) [0x001fe] in C:\project\Assets\External\Best HTTP\Examples\SignalRCore\Encoders\MessagePackProtocol.cs:148 
  at BestHTTP.SignalRCore.HubConnection.SendMessage (BestHTTP.SignalRCore.Messages.Message message) [0x0003b] in C:\project\Assets\External\Best HTTP\Source\SignalRCore\HubConnection.cs:611

Looking at EncodeMessage in MessagePackProtocol.cs, it looks like there's a hard-coded buffer size of 256 bytes. The MsgPackWriter.DEFAULT_BUFFER_SIZE is 32, which implies to me it means something different than the MsgPackReader.DEFAULT_BUFFER_SIZE which is 8k.

request.Response.GetHeaderValues(string s) doesn't work correctly

Hello, I try to get header info from https request.responce
It must be something like key - "Content-Disposition", value - "attachment; filename="IMG_20200730_233442.jpg"
But after

                foreach (var head in request.Response.Headers)
                {
                    Debug.Log(head.Key.ToString() + ": " + request.Response.GetHeaderValues(head.Key.ToString())); 
                }

I've got "content-disposition: System.Collections.Generic.List`1[System.String]"

Websocket go to "sleep" after 15 minutes

Hello. I used to create new web socket

        IEnumerator IEConnectToWS()
        {
            m_webSocket = new WebSocket(new Uri(wsServerAddress));
            m_webSocket.OnOpen += WSConnected;
            m_webSocket.OnMessage += WSProcessMessage;
            m_webSocket.OnError += WSError;
            m_webSocket.OnClosed += WSClosed;

            m_webSocket.Open();
        }

And if I send nothing on it in 15 minutes, after I try to send something it gets an error

2020.11.27 02:59:02.282 WSError on Request Finished with Error! Exception: Unable to read data from the transport connection: Connection reset by peer. at System.Net.Sockets.NetworkStream.Read (System.Byte[] buffer, System.Int32 offset, System.Int32 size) [0x00000] in <00000000000000000000000000000000>:0 
2020.11.27 02:59:02.282 BestHTTP.Extensions.ReadOnlyBufferedStream.Read (System.Byte[] buffer, System.Int32 offset, System.Int32 size) [0x00000] in <00000000000000000000000000000000>:0 
2020.11.27 02:59:02.282 BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities.IO.Streams.ReadFully (System.IO.Stream inStr, System.Byte[] buf, System.Int32 off, System.Int32 len) [0x00000] in <00000000000000000000000000000000>:0 
2020.11.27 02:59:02.282 BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Tls.TlsUtilities.ReadAllOrNothing (System.Int32 length, System.IO.Stream input) [0x00000] in <00000000000000000000000000000000>:0 
2020.11.27 02:59:02.282 BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Tls.RecordStream.ReadRecord () [0x00000] in <00000000000000000000000000000000>:0 
2020.11.27 02:59:02.282 23671 23687 Info Unity at BestHTTP.SecureProtocol.Org.Bo

It happens only on android, so I got logs from Unity Android Logcat.

The reason why I think that WebSocket goes to sleep is that when I send some garbage message on it every 30 sec, it has no error and successfully passed the needed message.

I tried to use

m_webSocket.CloseAfterNoMesssage = new TimeSpan(2, 0, 0);

but it didn't help.

How can I stop WebSocket to fall asleep?

Best regards,
Mike

UploadStream's Dispose called from SendOutTo only

If there's a connection issue, or other errors, the stream assigned to UploadStream remains open until the system calls its Dispose. Sooner or later it's going to be closed, but it would be better to happen sooner.

[WebSocket] OnError handling can double-log errors

This is maybe more of a suggestion, but when a WebSocket encounters an error, it will run this code:

if (OnError != null)
    OnError(this, reason);
if (OnError == null && OnError == null)  // this is odd
    HTTPManager.Logger.Error("WebSocket", reason);

My OnError callback logs the error, then unregisters all the callbacks and nulls out the socket. However, because this code checks the callback again, it ends up logging the error twice, and it would be nice if it didn't do that. Maybe the double null check should just be an else?

annot write application data on closed/failed TLS connection on iOs

got this error on ios while downloading assetbundles and turning on and off wifi connection, is there is something that I can do to fix this issue?

Ex [HTTP2Handler]: Sender thread - Message: 1: Cannot write application data on closed/failed TLS connection   at BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Tls.TlsProtocol.WriteData (System.Byte[] buf, System.Int32 offset, System.Int32 len) [0x00000] in :0 
  at BestHTTP.Extensions.WriteOnlyBufferedStream.Flush () [0x00000] in :0 
  at BestHTTP.Connections.HTTP2.HTTP2Handler.RunHandler () [0x00000] in :0 
  at BestHTTP.Connections.HTTPConnection.ThreadFunc () [0x00000] in :0 
  at System.Action.Invoke () [0x00000] in :0 
  at System.Threading.ParameterizedThreadStart.Invoke (System.Object obj) [0x00000] in :0 
  at System.Threading.ContextCallback.Invoke (System.Object state) [0x00000] in :0 
  at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in :0 
  at System.Threading.ParameterizedThreadStart.Invoke (System.Object obj) [0x00000] in :0   StackTrace:   at BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Tls.TlsProtocol.WriteData (System.Byte[] buf, System.Int32 offset, System.Int32 len) [0x00000] in :0 
  at BestHTTP.Extensions.WriteOnlyBufferedStream.Flush () [0x00000] in :0 
  at BestHTTP.Connections.HTTP2.HTTP2Handler.RunHandler () [0x00000] in :0 
  at BestHTTP.Connections.HTTPConnection.ThreadFunc () [0x00000] in :0 
  at System.Action.Invoke () [0x00000] in :0 
  at System.Threading.ParameterizedThreadStart.Invoke (System.Object obj) [0x00000] in :0 
  at System.Threading.ContextCallback.Invoke (System.Object state) [0x00000] in :0 
  at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in :0 
  at System.Threading.ParameterizedThreadStart.Invoke (System.Object obj) [0x00000] in :0

MessagePack Vector3 native support

The Messagepack CSharp (https://github.com/neuecc/MessagePack-CSharp) implementation provides a additional Resolver for Vector3 Unity but the types never matches as Vector3 does not seem to be a default type which is send with the additional header informations needed to support this feature on the server side.

It would be very helpful to have the possibility to send Unity data types directly over SignalR Core.

Reconnect failing when receiving a probe packet

Greetings,

I have an issue using socketIO through your asset, I'll try and describe you as best as I can the context.

The server I'm connecting to is using a longpolling transporter with websocket upgradable handshake. The server itself is in a cluster mode balanced with aws ALB, with sticky sessions enabled.

Sometimes when connecting to it I'm receiving a "Status Code: 400- Message: {"code":1,"message":"Session ID unknown"}" which then fails to reconnect. I've tried and debug the reason why this happens, what I saw was that when I receive that error I'm receiving a probe message from the server, which puts the State of the SocketManager in Pause. When this happens I've seen that on the OnHeartbeatUpdate method I'm correctly going in the Pause switch case but the Transport is actually null, so the check below fails when checking if the request or polling are in progress.

void IHeartbeat.OnHeartbeatUpdate(TimeSpan dif)
{
    switch (State)
    {
        case States.Paused:
        // To ensure no messages are lost, the upgrade packet will only be sent once all the buffers of the existing transport are flushed and the transport is considered paused.
        if (!Transport.IsRequestInProgress &&
               !Transport.IsPollingInProgress)
        {
            State = States.Open;

            // Close the current transport
            Transport.Close();

            // and switch to the newly upgraded one
            Transport = UpgradingTransport;
            UpgradingTransport = null;

            // We will send an Upgrade("5") packet.
            Transport.Send(new Packet(TransportEventTypes.Upgrade, SocketIOEventTypes.Unknown, "/", string.Empty));

            goto case States.Open;
         }

At first I've tried to get around this issue by resetting my connection when I was only receiving a Disconnect event without having first connected, but then I've noticed that even if I received a connection event I could still receive a subsequent disconnect and then failing to retry.

Hope this was as clear as possible, thanks in advance!

.Net Core support on other platforms?

There are #if NETFX_CORE macros in the source, but it seems only work on windows.
Any plan to support .Net Core so that BestHttp can run on linux/osx?

SocketIO Packet.Payload returns an array with the eventname and payload

// connector
    private void OnConnect() {
      Debug.Log($"Player name {PlayerName.text}");

      _helloEvent = new HelloEvent(PlayerName.text);

      var events = new List<BaseEvent> {
        _helloEvent, new InjectedInWorld(),
      };

      foreach (var ev in events.Where(ev => ev.IsCallable)) {
        _connector.Socket.On(ev.Name as string, ev.Callback);
      }

      _helloEvent.EmitSelf();
    }
    
    public void Connect() {
      _connector.Connect();
      _connector.Socket.On(SocketIOEventTypes.Connect, (s, p, a) => {
        OnConnect();
      });
    }

  public class InjectedInWorld : BaseEvent {
    
    public InjectedInWorld() : base(EventsNames.InjectedInWorld, true) { }

    public override void Callback(Socket socket, Packet packet, object[] args) {
      //var s = JsonUtility.FromJson<Player>(packet.Payload); // This breaks, [{"msg": "JSON must represent an object type." 
      Debug.Log("Payload from InjectedIntoWorld -> " + packet.Payload); // ['eventname', {event: "payload"}]
    }
  }

I read in the documentation that using autodecode = true would return the event as [string, {}] so i didn't provided that value -- but I still get it like so.

There's really no problem, it's just that I'm having trouble parsing the packet.Payload; Any help would be appreciated

Fail to connect to local socket.io server

I'm running into the following error when trying to connect to a local socket.io 2.1.1 server.

I'm able to connect to the local socket.io server using a test app running "socket.io-client": "^2.0.4"

Internal error! Message: Request Finished with Error! Exception: Network error! TCP Connection got closed before receiving any data!  at BestHTTP.HTTPResponse.Receive (System.Int32 forceReadRawContentLength, System.Boolean readPayloadData, System.Boolean sendUpgradedEvent) [0x0013a] in /Users/jrabek/projects/guess-the-word/unityClient/Assets/Best HTTP/Source/HTTPResponse.cs:266 
  at BestHTTP.Connections.HTTP1Handler.Receive (BestHTTP.HTTPRequest request) [0x0008d] in /Users/jrabek/projects/guess-the-word/unityClient/Assets/Best HTTP/Source/Connections/HTTP1Handler.cs:222 
  at BestHTTP.Connections.HTTP1Handler.RunHandler () [0x00139] in /Users/jrabek/projects/guess-the-word/unityClient/Assets/Best HTTP/Source/Connections/HTTP1Handler.cs:68 
UnityEngine.Debug:Log(Object)
NetworkManager:OnSocketError(Socket, Packet, Object[]) (at Assets/Scripts/NetworkManager.cs:169)
BestHTTP.SocketIO.Events.EventDescriptor:Call(Socket, Packet, Object[]) (at Assets/Best HTTP/Source/SocketIO/Events/EventDescriptor.cs:74)
BestHTTP.SocketIO.Events.EventTable:Call(String, Packet, Object[]) (at Assets/Best HTTP/Source/SocketIO/Events/EventTable.cs:85)
BestHTTP.SocketIO.Socket:BestHTTP.SocketIO.ISocket.EmitEvent(String, Object[]) (at Assets/Best HTTP/Source/SocketIO/Socket.cs:465)
BestHTTP.SocketIO.SocketManager:BestHTTP.SocketIO.IManager.EmitEvent(String, Object[]) (at Assets/Best HTTP/Source/SocketIO/SocketManager.cs:601)
BestHTTP.SocketIO.SocketManager:BestHTTP.SocketIO.IManager.EmitEvent(SocketIOEventTypes, Object[]) (at Assets/Best HTTP/Source/SocketIO/SocketManager.cs:609)
BestHTTP.SocketIO.SocketManager:BestHTTP.SocketIO.IManager.EmitError(SocketIOErrors, String) (at Assets/Best HTTP/Source/SocketIO/SocketManager.cs:614)
BestHTTP.SocketIO.SocketManager:BestHTTP.SocketIO.IManager.OnTransportError(ITransport, String) (at Assets/Best HTTP/Source/SocketIO/SocketManager.cs:450)
BestHTTP.SocketIO.Transports.WebSocketTransport:OnError(WebSocket, String) (at Assets/Best HTTP/Source/SocketIO/Transports/WebSocketTransport.cs:257)
BestHTTP.WebSocket.WebSocket:OnInternalRequestCallback(HTTPRequest, HTTPResponse) (at Assets/Best HTTP/Source/WebSocket/WebSocket.cs:344)
BestHTTP.Core.RequestEventHelper:HandleRequestStateChange(RequestEventInfo) (at Assets/Best HTTP/Source/Core/RequestEvents.cs:324)
BestHTTP.Core.RequestEventHelper:ProcessQueue() (at Assets/Best HTTP/Source/Core/RequestEvents.cs:224)
BestHTTP.HTTPManager:OnUpdate() (at Assets/Best HTTP/Source/HTTPManager.cs:414)
BestHTTP.HTTPUpdateDelegator:Update() (at Assets/Best HTTP/Source/HTTPUpdateDelegator.cs:171)

My server code:

start (config, cb) {
    console.log('Starting with config', config)

    this.app = express()
    this.app.use(morgan('combined'))
    let server = http.createServer(this.app)
    this.io = socketIo(server)

    this.gameIo = this.io.of('/game')
    this.gameIo.on('connection', this.connection_.bind(this))

    this.app.get('/health', function (req, res) {
      res.status(200).send('ok')
    })

    server.listen(config.port, cb)
  }

My client code:

    private void Connect()
    {

        Debug.Log($"Connecting to {url}");

        SocketOptions options = new SocketOptions();
        options.ConnectWith = BestHTTP.SocketIO.Transports.TransportTypes.WebSocket;
        options.ServerVersion = SupportedSocketIOVersions.v2;

        manager = new SocketManager(new Uri(url), options);

        ...
}

If I don't use the following I get 404s for /socket.io or /game or whatever path I use.

options.ConnectWith = BestHTTP.SocketIO.Transports.TransportTypes.WebSocket;

If I do use the websocket option then I get the error I posted above independent if I include /socket.io in the path

Network error! TCP Connection got closed before receiving any data!  

SSE(Server-Sent Events) does not work at BestHTTP 2.0.5

Testing with the SSE example provided, It received nothing after a while, and the OnError/OnClosed of EventSource does not be called.
There is a log [HTTP2Stream]: [1] State changed from HalfClosedLocal to Closed in console of Unity .

[SignalrCore] Send/Invoke tasks don't complete if disconnected

If the connection is not currently connected, then InvokeImp will return early and the returned task will never complete. If the connection is lost during a pending invocation, then the task will never complete.

It also looks like there's a bug where Send will always register as an invocation and send an invocation id? The signalrcore spec says that non-blocking sends should send a nil invocation id.

socket.io custom headers

It would be great to have some sort of customHeaders dictionnary in the SocketOptions of SocketIO to be able to inject some custom headers in the websocket http request or polling one.

I could make you the needed changes if you tell me that you could add them to your library

[WebSocket] newFrameSignal access is not thread safe

When I hit the End Play button in the Unity editor while I have an active web socket connection, I sometimes (maybe 50% of the time?) get one of two different errors:

ObjectDisposedException: Safe handle has been closed
System.Runtime.InteropServices.SafeHandle.DangerousAddRef (System.Boolean& success) (at <437ba245d8404784b9fbab9b439ac908>:0)
System.Threading.NativeEventCalls.SetEvent (Microsoft.Win32.SafeHandles.SafeWaitHandle handle) (at <437ba245d8404784b9fbab9b439ac908>:0)
System.Threading.EventWaitHandle.Set () (at <437ba245d8404784b9fbab9b439ac908>:0)
(wrapper remoting-invoke-with-check) System.Threading.EventWaitHandle.Set()
BestHTTP.WebSocket.WebSocketResponse.CloseWithError (BestHTTP.HTTPRequestStates state, System.String message) (at Assets/External/Runtime/Best HTTP/Source/WebSocket/WebSocketResponse.cs:658)
BestHTTP.WebSocket.WebSocketResponse.BestHTTP.Core.IProtocol.CancellationRequested () (at Assets/External/Runtime/Best HTTP/Source/WebSocket/WebSocketResponse.cs:678)
BestHTTP.Core.ProtocolEventHelper.CancelActiveProtocols () (at Assets/External/Runtime/Best HTTP/Source/Core/ProtocolEvents.cs:95)
BestHTTP.HTTPManager.AbortAll () (at Assets/External/Runtime/Best HTTP/Source/HTTPManager.cs:416)
BestHTTP.HTTPManager.OnQuit () (at Assets/External/Runtime/Best HTTP/Source/HTTPManager.cs:388)
BestHTTP.HTTPUpdateDelegator.OnApplicationQuit () (at Assets/External/Runtime/Best HTTP/Source/HTTPUpdateDelegator.cs:232)

or

NullReferenceException: Object reference not set to an instance of an object
BestHTTP.WebSocket.WebSocketResponse.CloseWithError (BestHTTP.HTTPRequestStates state, System.String message) (at Assets/External/Runtime/Best HTTP/Source/WebSocket/WebSocketResponse.cs:658)
BestHTTP.WebSocket.WebSocketResponse.BestHTTP.Core.IProtocol.CancellationRequested () (at Assets/External/Runtime/Best HTTP/Source/WebSocket/WebSocketResponse.cs:678)
BestHTTP.Core.ProtocolEventHelper.CancelActiveProtocols () (at Assets/External/Runtime/Best HTTP/Source/Core/ProtocolEvents.cs:95)
BestHTTP.HTTPManager.AbortAll () (at Assets/External/Runtime/Best HTTP/Source/HTTPManager.cs:416)
BestHTTP.HTTPManager.OnQuit () (at Assets/External/Runtime/Best HTTP/Source/HTTPManager.cs:388)
BestHTTP.HTTPUpdateDelegator.OnApplicationQuit () (at Assets/External/Runtime/Best HTTP/Source/HTTPUpdateDelegator.cs:232)

It looks like this is just a simple race condition between the background thread disposing and nulling newFrameSignal and the main thread trying to set it.

BestHTTP.WebSocket.WebSocketResponse:ReceiveThreadFunc() (at Assets/External/Runtime/Best HTTP/Source/WebSocket/WebSocketResponse.cs:508)
BestHTTP.PlatformSupport.Threading.<>c__DisplayClass4_0:<RunLongLiving>b__0() (at Assets/External/Runtime/Best HTTP/Source/PlatformSupport/Threading/ThreadedRunner.cs:79)
System.Threading.ThreadHelper:ThreadStart(Object)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.