question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Deserialization exception when using compression and SSL together

See original GitHub issue

CC: @developervariety since this was his enhancement request

Steps to reproduce:

  1. instantiate both server and client using SSL
  2. set client compression mode to Gzip or Deflate
  3. send two or more messages

First message received ok: image

Second message: image

Exception output:

Exception while deserializing (note the binary data prior to the JSON metadata)
?l\M   {"Status":"Normal","SyncRequest":false,"SyncResponse":false,"Compression":"Gzip","ContentLength":26,"Metadata":{}}



Exception:
{
  "ClassName": "Newtonsoft.Json.JsonReaderException",
  "Message": "Unexpected character encountered while parsing value: ?. Path '', line 0, position 0.",
  "Data": null,
  "InnerException": null,
  "HelpURL": null,
  "StackTraceString": "   at Newtonsoft.Json.JsonTextReader.ParseValue()\r\n   at Newtonsoft.Json.JsonReader.ReadForType(JsonContract contract, Boolean hasConverter)\r\n   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)\r\n   at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)\r\n   at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)\r\n   at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings)\r\n   at WatsonTcp.SerializationHelper.DeserializeJson[T](String json)",
  "RemoteStackTraceString": null,
  "RemoteStackIndex": 0,
  "ExceptionMethod": "8\nParseValue\nNewtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed\nNewtonsoft.Json.JsonTextReader\nBoolean ParseValue()",
  "HResult": -2146233088,
  "Source": "Newtonsoft.Json",
  "WatsonBuckets": null
}

[WatsonMessage] BuildStream exception:
{
  "ClassName": "Newtonsoft.Json.JsonReaderException",
  "Message": "Unexpected character encountered while parsing value: ?. Path '', line 0, position 0.",
  "Data": null,
  "InnerException": null,
  "HelpURL": null,
  "StackTraceString": "   at WatsonTcp.SerializationHelper.DeserializeJson[T](String json)\r\n   at WatsonTcp.WatsonMessage.<BuildFromStream>d__36.MoveNext()",
  "RemoteStackTraceString": null,
  "RemoteStackIndex": 0,
  "ExceptionMethod": "8\nParseValue\nNewtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed\nNewtonsoft.Json.JsonTextReader\nBoolean ParseValue()",
  "HResult": -2146233088,
  "Source": "Newtonsoft.Json",
  "WatsonBuckets": null
}

Theory: it seems the compression stream is not being read fully, or, when reading, the position is not advancing.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
developervarietycommented, Apr 19, 2020

I knew only reading the ContentLength provided number was the issue here! I’m surprised it was JSON.NET throwing the error instead of the compressor trying to decompress the stream/data.

Reading the full stream will keep #74 ContentLength intact as desired by design.

Glad to see the issue has been resolved. Thank you!

0reactions
jchristncommented, Apr 19, 2020

NuGet v4.1.3: https://www.nuget.org/packages/WatsonTcp/4.1.3 Commit: https://github.com/jchristn/WatsonTcp/commit/34d5cde5f55826e83e0684f4ed5d5741e3a3a14e

@developervariety I hope some of the internal refactoring doesn’t throw off your PR too much. Cheers and have a good night

Read more comments on GitHub >

github_iconTop Results From Across the Web

Java RMI + SSL + Compression = IMPOSSIBLE!
The client socket factories will be serialized and passed from the server to the client together with the remote stubs, allowing the client ......
Read more >
mod_ssl - Apache HTTP Server Version 2.4
The ssl provider allows access if the user is authenticated with a valid client certificate. This is only useful if SSLVerifyClient optional is...
Read more >
4.2.3 Command Options for Connecting to the Server
When you invoke a MySQL client program with the --ssl-session-data option, the client attempts to deserialize session data from the file, if provided,...
Read more >
Serialization Configuration Wrap-Up
This section summarizes the configuration of serialization options, ... enable-compression : Enables compression if default Java serialization is used.
Read more >
Apache Kafka Reference Guide
The handler is called with details of the deserialization, including the action represented as Uni<T> . On the deserialization Uni failure strategies like...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found