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

Gremlin.NET : WebSocketConnection does not check for MessageType.Close, causing error InvalidOperationException: "Received data deserialized into null object message. Cannot operate on it."

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 3.4.13, 3.5.2
    • 3.6.0, 3.5.3
    • dotnet
    • None

    Description

      Issue:

      If the server sends a valid Close websocket message to the client, the client will throw InvalidOperationException rather than acknowledge/cleanup the connection gracefully.

      See relevant point where exception is thrown. here

      Close messages from the server can be expected when the server is doing a graceful shutdown, and clients would be expected to reconnect.

      Details:

      A Close websocket message being received by ClientWebSocket, WebSocketReceiveResult.MessageType will return MessageType.Close. In this case, the message buffer will be zero-bytes, see these remarks.

      Currently, Gremlin.NET does not check for this message type in WebSocketConnection.ReceiveMessageAsync and return a zero-length buffer. In Connection.HandleReceiveAsync, the attempt to deserialize the empty buffer returns `null` and the check fails.

      Potential Fix

      1. If `MessageType == Close` Throw a new connection closed exception from WebSocketConnection.ReceiveMessageAsync which includes WebSocketReceiveResult.CloseStatus and WebSocketReceiveResult.CloseDescription in the exception message and as properties.
      2. This will be caught in Connection.HandleRecieveAsync and treated as fatal and will call CloseConnectionBecauseOfFailureAsync and will handle completing the close handshake, and notifies pending requests on the connection with the closed connection exception.

      Attachments

        Activity

          People

            Florian Hockmann Florian Hockmann
            olivertowers Oliver Towers
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: