Skip to content

$type deserialization issue in IMutableMessage #42

@kathariyasunny16

Description

@kathariyasunny16

When i am running the Salesforce subscriber, sometime i receive below log in outbound meta message { "channel": "/meta/handshake", "supportedConnectionTypes": { "$type": "System.Collections.ObjectModel.ReadOnlyCollection1[[System.String, System.Private.CoreLib]], System.Private.CoreLib", "$values": [ "long-polling" ] }, "version": "1.0", "id": "1" }

instead of {"channel":"/meta/handshake","supportedConnectionTypes":["long-polling"],"version":"1.0","id":"1"}

Why this is happening? whenever i have a message with $type my handshake fails.

It's mostly because of code in src/CometD.NetCore/Common/DictionaryMessage.cs class and code is :
var dictionaryList = JsonConvert.DeserializeObject<IList<IDictionary<string, object>>>(content);

We are not specifying the default settings of JSON convert
JsonConvert.DefaultSettings = () => new JsonSerializerSettings
{
Formatting = Formatting.Indented,
TypeNameHandling = TypeNameHandling.None, //Prevents $type issue
ContractResolver = new CamelCasePropertyNamesContractResolver(),
ReferenceLoopHandling = ReferenceLoopHandling.Ignore
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions