Currently using protobuf with ServiceStack inside my Angular application using protobufjs and everything is working great.
My only issue occurs when, for example, performing a delete operation and an exception is thrown and a generic ErrorResponse is returned. I don’t seem to be able to decode this protobuf data in my application. I’ve setup the appropriate .proto files etc but I’m getting an invalid wire type 7 error?
Why aren’t you using JSON in a web application? It’s typically faster to use the browsers native JSON parser than a custom serialization library. What library are you using to deserialize the protobuf messages, it would need to deserialize the Error in the ErrorResponse DTO which is just a generic DTO containing a ResponseStatus property, e.g:
[DataContract]
public class ErrorResponse : IHasResponseStatus
{
[DataMember(Order = 1)]
public ResponseStatus ResponseStatus { get; set; }
}
You can avoid using the generic ErrorResponse DTO by creating explicit Response DTOs which contain the ResponseStatus property, e.g:
class DeleteCustomer : IReturn<DeleteCustomerResponse> { ... }
class DeleteCustomerResponse
{
public ResponseStatus ResponseStatus { get; set; }
}
Utilising protobuf because the application is transferring a lot of data between internal services, as well as to web browsers, and wanted the benefits.
Once I’ve converted some ‘valid’ arraybuffer output to base64 and placed in that tool, I can see the various fields and data displayed. When I catch the subscribe error and place the err.error arraybuffer data into the tool I receive a wire error:
This may be resolved from the commit mentioned in this post, if it’s still an issue I’d need a stand-alone repro or failing test I can run locally to repro the issue.