microsoft / microsoft/vs-streamjsonrpc

ConnectionLostException when invoking re-assigned Remote Targets

Open
#878 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
937
Forks
178
Avg merge
3d 1h
Merged PRs (30d)
28

Description

Version: 2.6.121
Caller: .NET 4.7.2

Exception:

JsonRpc Error: 10 : Exception thrown from request "68" for method syncElement: StreamJsonRpc.ConnectionLostException: The JSON-RPC connection with the remote party was lost before the request could complete. ---> System.OperationCanceledException: The operation was canceled.
   at System.Threading.CancellationToken.ThrowOperationCanceledException()
   at StreamJsonRpc.MessageHandlerBase.<WriteAsync>d__23.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at StreamJsonRpc.JsonRpc.<TransmitAsync>d__159.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Threading.Tasks.ValueTask.ThrowIfCompletedUnsuccessfully()
   at StreamJsonRpc.JsonRpc.<InvokeCoreAsync>d__143.MoveNext()
   --- End of inner exception stack trace ---
   at StreamJsonRpc.JsonRpc.<InvokeCoreAsync>d__143.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
   at StreamJsonRpc.JsonRpc.<DispatchIncomingRequestAsync>d__147.MoveNext()
JsonRpc Error: 10 : StreamJsonRpc.ConnectionLostException: The JSON-RPC connection with the remote party was lost before the request could complete. ---> System.OperationCanceledException: The operation was canceled.
   at System.Threading.CancellationToken.ThrowOperationCanceledException()
   at StreamJsonRpc.MessageHandlerBase.<WriteAsync>d__23.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at StreamJsonRpc.JsonRpc.<TransmitAsync>d__159.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Threading.Tasks.ValueTask.ThrowIfCompletedUnsuccessfully()
   at StreamJsonRpc.JsonRpc.<InvokeCoreAsync>d__143.MoveNext()
   --- End of inner exception stack trace ---
   at StreamJsonRpc.JsonRpc.<InvokeCoreAsync>d__143.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
   at StreamJsonRpc.JsonRpc.<DispatchIncomingRequestAsync>d__147.MoveNext(), syncElement, 68, Newtonsoft.Json.Linq.JToken[]
JsonRpc Information: 8 : {"id":68,"error":{"code":-32000,"message":"The JSON-RPC connection with the remote party was lost before the request could complete."}}
JsonRpc Verbose: 8 : Sent: {
  "jsonrpc": "2.0",
  "id": 68,
  "error": {
    "data": {
      "type": "StreamJsonRpc.ConnectionLostException",
      "message": "The JSON-RPC connection with the remote party was lost before the request could complete.",
      "stack": "   at StreamJsonRpc.JsonRpc.<InvokeCoreAsync>d__143.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)\r\n   at StreamJsonRpc.JsonRpc.<DispatchIncomingRequestAsync>d__147.MoveNext()",
      "code": -2146233088,
      "inner": {
        "type": "System.OperationCanceledException",
        "message": "The operation was canceled.",
        "stack": "   at System.Threading.CancellationToken.ThrowOperationCanceledException()\r\n   at StreamJsonRpc.MessageHandlerBase.<WriteAsync>d__23.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at StreamJsonRpc.JsonRpc.<TransmitAsync>d__159.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Threading.Tasks.ValueTask.ThrowIfCompletedUnsuccessfully()\r\n   at StreamJsonRpc.JsonRpc.<InvokeCoreAsync>d__143.MoveNext()",
        "code": -2146233029,
        "inner": null
      }
    },
    "code": -32000,
    "message": "The JSON-RPC connection with the remote party was lost before the request could complete."
  }
}

Signature of the called method:

Remote 1 starts

Client 1 starts

Client 1 calls client1.Rpc.AddRemoteTarget(remote1)

Client 1 makes some calls to Remote 1.

.....

The Server closes the socket associated with Remote 1, disposes the Rpc.

Remote 2 starts, implementing the same targets.

Client 1 calls client1.Rpc.AddRemoteTarget(remote2)

Client 1 tries to make some calls to Remote 2. However, each call throws a ConnectionLostException whenever the server tries to call any remote method.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the sequence in the issue: dispose the first remote connection, add a replacement with Rpc.AddRemoteTarget, then invoke the remote method and observe syncElement. Trace AddRemoteTarget and the syncElement call path to determine why the replaced target still loses its connection. Done means calls to the replacement remote target complete without ConnectionLostException.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
api, distributed-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.