Deserialization exception when using compression and SSL together
See original GitHub issueCC: @developervariety since this was his enhancement request
Steps to reproduce:
- instantiate both server and client using SSL
- set client compression mode to
Gzip
orDeflate
- send two or more messages
First message received ok:
Second message:
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:
- Created 3 years ago
- Comments:7 (5 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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!
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