grpc / grpc-web

gRPC for Web Clients
https://grpc.io
Apache License 2.0
8.51k stars 766 forks source link

Intermittently getting an "Unknown base64 encoding at char:" message #1238

Open psantoli opened 2 years ago

psantoli commented 2 years ago

Hello,

We have a C# Grpc.AspNetCore version 2.27.0 service that sends image data to a grpc-web client using grpc-web version 1.3.1 and google-protobuf version 3.14.0, to an AngularJS application running in a Chrome browser that displays images on the page as they are sent from the gRPC service.

Occasionally there is an uncaught error that shows up in the Chrome console that has the following message: “Uncaught Error: Unknown base64 encoding at char:”, followed by another error that reads: “Error: The stream is broken @####/####. Error: invalid frame byte. With input:”. When this unknown base64 error occurs, all subsequent images sent from the gRPC service will no longer be displayed in the grpc-web browser client.

Further analysis of the base64 encoded data from what the gRPC service is sending to what is displayed in the Chrome console when the issue occurs indicates that the base64 data is correct for a while, but then starts to diverge until the unknown base64 encoded character is encountered. Below is a comparison of the base64 encoded data that is received by the grpc-web client on the left and what the gRPC service had sent on the right. The area highlighted in grey is where the data received by the grpc-web client starts to diverge from the data that the gRPC service had sent and eventually the unknown base64 character shows up in the data on the left: image

It would seem that something is corrupting the base64 encoded data that the grpc-web client is receiving but we haven’t been able to determine where this corruption may be coming from.

It usually takes several sequences of image file transmissions before the error starts happening, with the total being around several hundreds of MB of image data (~1mb at a time), and we’re closing and reopening the client/server connection between each sequence.

We’ve also tested the same server with a C# client standing in for the grpc-web client and have not observed the same errors. We were hoping that someone could provide some information or guidance that could help to identify what might be going on.

For reference, here is the .proto file we are using in the gRPC service: syntax = "proto3";

package imagestream;

service ImageStream { rpc GetImages(ImageRequest) returns (stream Image) {} }

message Image { bytes rawBytes = 1; }

message ImageRequest { string ViewId = 1; }

Thank you.