Uploaded image for project: 'TinkerPop'
  1. TinkerPop
  2. TINKERPOP-2019

Gremlin.Net.Driver.WebSocketConnection throws System.InvalidOperationException

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Reopened
    • Priority: Critical
    • Resolution: Unresolved
    • Affects Version/s: 3.3.3
    • Fix Version/s: None
    • Component/s: dotnet
    • Labels:
      None
    • Environment:
      Azure App Service

      Description

      We're getting the following System.InvalidOperationException error message:

      "There is already one outstanding 'SendAsync' call for this WebSocket instance. ReceiveAsync and SendAsync can be called simultaneously, but at most one outstanding operation for each of them is allowed at the same time.
      Problem Id:
      System.InvalidOperationException at Gremlin.Net.Driver.WebSocketConnection+<SendMessageAsync>d__5.MoveNext"

       
      We get this exception sporadically and only a few times out of thousands. Unfortunately we have not been able to reproduce it.
       
      I understand that when dealing with web sockets, it is allowed to have only a single pending "send" or a single pending "receive".
       
      After looking at GitHub's WebSocketConnection class, I don't see any orchestration between SendMessageAsync's _client.SendAsync (currently line 54) and ReceiveMessageAsync's _client.ReceiveAsync (currently line 66). 
       
      Reference Link: 
      https://github.com/apache/tinkerpop/blob/master/gremlin-dotnet/src/Gremlin.Net/Driver/WebSocketConnection.cs
       
      I'm wondering if not having orchestration in the WebSocketConnection class to keep the single pending "send" or a single pending "receive" rule may be the cause. 
       
      In our .NET Core web api application, we create the GremlinConnection as a singleton in Startup.cs and then have one central call that makes Gremlin calls; i.e. it's a very straightforward implementation.
       
      Startup.cs:

      public void ConfigureServices(IServiceCollection services)
      {
          //...other stuff removed for brevity
          services.AddSingleton<IGremlinConnection, GremlinConnection>();
      }

       
      Reader.cs:

      public async Task<IReadOnlyCollection<dynamic>> ExecuteGremlinQuery(string query)
      {
          try
          {
              return await _gremlinConnection.Client.SubmitAsync<dynamic>(query);
          }
          catch (Gremlin.Net.Driver.Exceptions.ResponseException responseException)
          {
              //our error handling removed for brevity!    
          }
      }

       
      We use the Gremlin.Net version 3.3.3 nuget package and the Microsoft.NETCore.App SDK
       
      Would it be possible to identify if this is indeed a bug on Gremlin.NET? 
      And if it is, any thoughts on a best-practice (temporary) work-around that we can implement?

        Attachments

        1. invalid.txt
          65 kB
          Dzmitry.Lahoda
        2. image-2020-02-21-05-33-27-246.png
          52 kB
          Dzmitry.Lahoda
        3. image-2020-02-21-05-32-58-730.png
          52 kB
          Dzmitry.Lahoda

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              samimajed Sami
            • Votes:
              3 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

              • Created:
                Updated: