Hi Abp Team,
I am getting a JsonException when Project A publishes events to Project B. We are using RabbitMQ for event exchange. In the local environment, which is Windows, it works, but when published to Ubuntu, JsonExceptions are thrown.
Below is the JsonException that was thrown:
↓
<b>How can i solve this issue?</b>
8 Answer(s)
-
0
The
JsonReaderException
you are encountering ('{' is an invalid start of a property name. Expected a '\"'.
) typically indicates that the event payload being deserialized is not valid JSON. This often happens when the message is sent as plain text or another format (such as single-quoted JSON or a .NET object string) instead of standard double-quoted JSON.Since it works on Windows but fails on Ubuntu, the most common causes are:
- Inconsistent serialization settings between environments (e.g., using Newtonsoft.Json in one place and System.Text.Json in another).
- Locale or encoding differences (e.g., line endings, UTF-8/UTF-16).
- RabbitMQ message content-type or encoding differences.
How to Solve
Ensure Consistent Serialization
- Make sure both Project A (publisher) and Project B (consumer) use the same JSON serializer (preferably System.Text.Json for ABP v7+).
- Do not manually serialize/deserialize events; let ABP's distributed event bus handle it.
Check for Manual Serialization
- If you are manually serializing the event before publishing, remove that code. Publish the event object directly:
await _distributedEventBus.PublishAsync(new MyEventEto { ... });
- Do not use
JsonConvert.SerializeObject
or similar before publishing.
Check RabbitMQ Message Content-Type
- Ensure the message is published with
content-type: application/json
. - If you are using custom RabbitMQ code, set the content type explicitly.
- Ensure the message is published with
Check for OS-Specific Differences
- Make sure the .NET runtime and all dependencies are the same version on both Windows and Ubuntu.
- Check for any environment-specific configuration differences.
Clear Old Queues
- If you changed the event type or serialization, old messages in RabbitMQ may still be in the wrong format. Purge the relevant queues/exchanges in RabbitMQ to remove incompatible messages.
Review Event Contracts
- Ensure the event class (ETO) is identical in both projects (namespace, property names, etc.).
References
- Official ABP documentation on distributed event bus and RabbitMQ integration:
- Related support discussion:
These steps should help you resolve the cross-platform serialization issue with ABP distributed events and RabbitMQ.
This response was generated by AI. If it didn’t solve your problem, feel free to post a new answer — our support team will jump in to help you soon.
-
0
-
0
Yes , here is the event class
[EventName("Maintenance.Request.Closed")] public class MaintenanceRequestClosedEto { public Guid Id { get; set; } public DateTime ClosedDate { get; set; } }
and methode that handles event
public async Task HandleEventAsync(MaintenanceRequestClosedEto eventData) { var entity = await _repository.FindAsync(eventData.Id); entity.SetStatus(MaintenanceRequestStatus.Completed, eventData.ClosedDate); await _repository.UpdateAsync(entity); }
-
0
hi
Can you check the entity data in the database with
eventData.Id
?Key focus on the
ExtraProperties
property.Thanks.
-
0
Yes, in the _repository, for different eventData.Id in ExtraProperties has different values - some are {}, some are {{}}, and some are null.
-
0
hi
{}
andnull
is no problem.But
{{}}
is wrong.Do you remember why
{{}}
is write to database? Can you share some code?Thanks.
-
0
We solved the issue by updating ExtraProperties to {}.
Do you remember why {{}} was written to the database?
We are looking into it, and if any questions come up, we will ask.Thank you for the fast response.
-
0
Great