how to fix StreamJsonRpc.ConnectionLostException : The JSON-RPC connection with the remote party was lost before the request could complete. ---> System.OperationCanceledException : The operation was canceled.

Starfall Conquer 30 Reputation points

even upgrade to the latest Version 17.6.4

still does it, can even be idle when it happens, Super annoying.

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 async StreamJsonRpc.MessageHandlerBase.WriteAsync(<Unknown Parameters>)
 at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
 at async StreamJsonRpc.JsonRpc.SendAsync(<Unknown Parameters>)
 at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
 at async StreamJsonRpc.JsonRpc.InvokeCoreAsync(<Unknown Parameters>)
 --- End of inner exception stack trace ---
 at async StreamJsonRpc.JsonRpc.InvokeCoreAsync(<Unknown Parameters>)
 at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
 at async StreamJsonRpc.JsonRpc.InvokeCoreAsync[TResult](<Unknown Parameters>)
 at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
 at async Microsoft.CodeAnalysis.Remote.BrokeredServiceConnection`1.TryInvokeAsync[TService](<Unknown Parameters>)
  1. Giridhar Sadineni 0 Reputation points

    Facing the same issue as above. tried all suggested solutions but no luck. VS version 17.7.4

  2. JordiCasas-6718 1 Reputation point

    Same here.

  3. Gehan Fernando 15 Reputation points

    I am using VS 2022 17.7.4 version, and I am getting same error.

    To resolve this issue,

    1. Delete ComponentModelCache
    2. Repair VS 2022
    3. Re-Install VS 2022
    4. Format the machine and re-install VS 2022

    After all same error facing. Microsoft Can you fix this issue asap.

    StreamJsonRpc.ConnectionLostException : The JSON-RPC connection with the remote party was lost before the request could complete.
     at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
     at async StreamJsonRpc.JsonRpc.InvokeCoreAsync(<Unknown Parameters>)
     at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
     at async StreamJsonRpc.JsonRpc.InvokeCoreAsync[TResult](<Unknown Parameters>)
     at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
     at System.Threading.Tasks.ValueTask`1.get_Result()
     at async Microsoft.CodeAnalysis.Remote.BrokeredServiceConnection`1.TryInvokeAsync[TService,TResult](<Unknown Parameters>)
    
  4. Arno Marais2 0 Reputation points

    Facing the same issue

    Task Failed - Activating language client HtmlLanguageClient: HtmlLanguageClient failed to initialize. Please report a problem via Help -> Send Feedback -> Report a Problem. Status = Sending 'initialize' request. Exception = StreamJsonRpc.ConnectionLostException: The JSON-RPC connection with the remote party was lost before the request could complete.
     at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
     at StreamJsonRpc.JsonRpc.<InvokeCoreAsync>d__162.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
     at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
     at StreamJsonRpc.JsonRpc.<InvokeCoreAsync>d__151`1.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
     at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
     at Microsoft.VisualStudio.LanguageServer.Client.JsonRpcExtensionMethods.<SendMethodRequestWithTelemetryAsync>d__0`2.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
     at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
     at Microsoft.VisualStudio.LanguageServer.Client.RemoteLanguageClientInstance.<SendInitializeRequestAsync>d__120.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
     at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
     at Microsoft.VisualStudio.LanguageServer.Client.RemoteLanguageClientInstance.<InitializeAsync>d__117.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
     at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
     at Microsoft.VisualStudio.Threading.TplExtensions.<WithTimeout>d__5.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
     at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
     at Microsoft.VisualStudio.LanguageServer.Client.RemoteLanguageClientInstance.<TrackTaskAsync>d__118.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
     at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
     at Microsoft.VisualStudio.LanguageServer.Client.RemoteLanguageClientInstance.<ActivateLanguageClientAsync>d__127.MoveNext()
    
  5. Eddy, Christopher@DGS 0 Reputation points

    Hello,

    With 17.7.5 still having this same issue. Tried deleting the cache directory, no newtonsoft.

    [10/23/2023 1:25:57.467 PM] Log level is set to Trace (Includes Platform logs).
    [10/23/2023 1:26:00.013 PM] Interrupt: Enqueueing RunAllOperation
    [10/23/2023 1:26:00.014 PM] Enqueue operation 'RunAllOperation', hashcode:61510603 
    [10/23/2023 1:26:00.014 PM] Operation left in the the queue: 1
    [10/23/2023 1:26:00.014 PM] 	'RunAllOperation', hashcode:61510603
    [10/23/2023 1:26:00.014 PM] 
    
    [10/23/2023 1:26:00.014 PM] Operation Dequeue : 'RunAllOperation'
    [10/23/2023 1:26:00.016 PM] [Error] 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.ExceptionServices.ExceptionDispatchInfo.Throw()
     at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
     at StreamJsonRpc.JsonRpc.<SendAsync>d__157.MoveNext()
    

Sign in to comment

7 answers

  1. Tianyu Sun-MSFT 34,836 Reputation points β€’ Microsoft External Staff

    Hello @Starfall Conquer ,

    Welcome to Microsoft Q&A forum.

    I suggest first try cleaning VS cache(rename ComponentModelCache folder(s) in C:\Users\username\AppData\Local\Microsoft\VisualStudio\17.0_xxxxxxxx folder), and then reset VS(run devenv /ResetSettings command in Developer Command Prompt For Visual Studio 2022) => run Visual Studio as administrator.

    Sometimes, updating Windows OS or uninstalling Newtonsoft.Json assembly file(run gacutil -u Newtonsoft.Json in command prompt) works.

    Please feel free to let us know the results.

    Sincerely,

    Tianyu


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1. Starfall Conquer 30 Reputation points

      will give it a try today and let you know

    2. Starfall Conquer 30 Reputation points

      worked for a couple hours then returned

    3. Tianyu Sun-MSFT 34,836 Reputation points β€’ Microsoft External Staff

      Hi @Starfall Conquer ,

      Thanks for your reply.

      Did you use any extension or any third-party programs along with VS 2022? When did this error appear? Does this error appear in a specific situation or after some specific actions?

    4. Starfall Conquer 30 Reputation points

      it started approximately 2 weeks ago, its random when it happens, sometime i just open the project and get busy with something else and go back into it and it happened, so idle not doing anything or changing code, don't seam to make a diff. just updated windows and vs 2022 to 17.6.5 same thing. haven't seen it do it when there is not a project loaded thou. i don't use any 3rd party at all. idk why its even trying to connect to anything to check. ty for at least replying

    5. Starfall Conquer 30 Reputation points

      when i did the run gacutil -u Newtonsoft.Json in command prompt in vs code that just said it did not exist. which i dont use vs code, only downloaded it trying to sort this out


    Sign in to comment
  2. FallenDev 30 Reputation points

    This is still a major issue. I've followed multiple steps stated above and I'm still encountering this. It gets even more annoying where if you ignore it. Sometimes your visual studio just crashes out. Forget saving anything because you don't have time.

    Event logs show the following image. I've uninstalled all .NET Frameworks and reinstalled, I even clean installed Windows 11 Pro and did fresh everything. Still seeing this issue. πŸ‘ User's image

    Here's a view of what it looks like in my Visual Studio Enterprise 2022 (64-bit) 17.8.3
    πŸ‘ User's image

    Now I added the full photo, so you can see the scroll bar just goes on for days with errors. I'm also curious why Visual Studio is built with .NET Framework 4.8 when we're on .NET 8 now. This could very well be the issue since every month it seems Microsoft is pushing security patches for 4.8.

    Please fix this, it's become exhausting and I really don't feel like switching to Rider.

    1. Tianyu Sun-MSFT 34,836 Reputation points β€’ Microsoft External Staff

      Hello @FallenDev-1649,

      Thank you for taking time to post this issue in Microsoft Q&A forum.

      The error code -1073741819 seems to be related to access. Are you using any antivirus software, proxy, extension, or is there any permission limitation on your machine? Is this issue project-specific?

    2. Sebastian S 5 Reputation points

      @Tianyu Sun-MSFT

      I have the same exact issue. I noticed since 12/30/2023 I had an issue building my projects because of a false positive of Microsoft Antivirus. I added an exection for msbuild.exe, devenv.exe and my project folders. And the anitvirus error was gone. However since a few days I encountered this error code -1073741819 @FallenDev is describing.

    3. FallenDev 30 Reputation points

      @Tianyu Sun-MSFT Thank you for the reply, aye I also saw that. I actually tracked down this issue this morning as a faulty RAM stick. Currently running through the RMA process with GSkill. Seems I started having memory failure a few weeks ago and its causing access issues.

      Sorry for the miss association above, it mirrored itself as the problem mentioned prior, but seems mine is hardware related.

    4. Sebastian S 5 Reputation points

      Interesting, I will do a RAM check and report back.

    5. Sebastian S 5 Reputation points

      I ran diagnostics with the Microsoft Diagnostic Tool. It did not find any errors. I still have this problem


    Sign in to comment
  3. Luca Zoffoli 5 Reputation points

    To fix it I set "Run background analysis for" to "None".

    It’s not the real solution, but at least it didn’t give me more problems.πŸ‘ User's image

    1. Matthew Whited 11 Reputation points

      The only step I haven’t tried is a reformat… but it’s getting close.

      this issue still persists and seem to be getting worse with the copilot updates.


    Sign in to comment
  4. Maciej MilaΕ„ski 0 Reputation points

    Hi! I'm not sure in what scenario you're getting this error. In my case it was while trying to train model for text classification. When using vs22 the error occurred, but using mlnet cli tool allow me to train model succesfully. So it was solution for me.

    0 comments No comments

    Sign in to comment
  5. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

Sign in to answer

Your answer