We get these errors with GRPC client. Do you have a version for null safety ?
We have a null safe version of our servicestack Dart library for Dart Add ServiceStack Reference but we donât maintain any of the gRPC proto client libraries, that comes directly from grpc.io Dart library maintainers.
Does the ServiceStack 2.0 for dart work for flutter-web ? (for StreamServerEvents?)
The ServiceStack Dart library doesnât have an SSE/Server Events client.
what package we should use for StreamServerEvents.
I canât understand this command
rpc ServerStreamServerEvents(StreamServerEvents) returns (stream StreamServerEventsResponse) {}
do we create the protoc client ? not only the protobuf for request -response
Dartâs normal grpc packages, I wouldnât expect thereâd be others maintained for Dart.
For mobile Flutter application, connection with Servicestack API is working. The same with GRPC service.
But in flutter web we canât use that objects and with the web ones we have errors
For ServicestackAPI Connection we use that:
var client = new JsonWebClient(âhttps://www.techstacks.ioâ);
void _getContext() async{
var response = await client.get(GetTechnology(slug:âflutterâ));
_counter = response.technology.hashCode;
}
and we get errors like this:
TypeError: Cannot read property âstatusCodeâ of null
at http://localhost:61038/packages/servicestack/web_client.dart.lib.js:702:31
at web_client.JsonWebClient.new.handleError >
This error seems to come from inside of web_client.dart library
For GrpcWeb we use the GrpcWebClientChannel
Future doRemoteCall() async {
final channel = GrpcWebClientChannel.xhr(Uri.parse(âtodoworld.servicestack.net:50054â));
final client = EchoServiceClient(channel);
return (await client.echo(EchoRequest()âŚmessage = âhelloâ)).message;
}
And we are getting this error back:
Error: gRPC Error (code: 14, codeName: UNAVAILABLE, message: XhrConnection status 0, details: null, rawResponse: )
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/patch/core_patch.dart 909:28 get current
packages/grpc/src/client/transport/xhr_transport.dart 122:22
compiled with unsound null safety
This is the flutter mobile code working normally
For mobile Flutter application,
Connection with Servicestack API is working with code below
var client1 = JsonServiceClient(âhttps://techstacks.ioâ);
void _callService() async {
var response = await client1.get(GetTechnology(slug:âflutterâ));
setState(() {
result = response.technology!.description!;
});
}
Connection with grpc service also working
GrpcServicesClient client1 = GrpcServicesClient(
ClientChannel(âtodoworld.servicestack.netâ, port:50054,
options:ChannelOptions(credentials: ChannelCredentials.insecure())));
void _callGrpcService() async {
var response = await client1.getHello(Hello()âŚname=âFlutter gRPCâ);
setState(() {
result = response.result;
});
}
Iâm assuming youâre running into a CORS error, you wont be able to make cross domain requests from any website unless the cross domain server explicitly authorizes the origin url youâre making the request from.
Whatâs the actual HTTP Request/Response headers made by the web client?
We can answer you tomorrow when the developer works again. I think he used your code example from the documentation. He calls the âhttps://www.techstacks.ioâ
You canât break web laws, donât try to make cross origin requests unless you know itâs explicitly allowed from your domain, make it to your own APIs that you can control instead, if the API is hosted on a different domain from the Web App register the CorsFeature
plugin with the origin youâre calling from.
I know for the CORS feature in our API. Developer tried to test if the GRPC works as the example for the flutter -web
@mythz we have another problem now. The request was served by the service but it returns this error
Can you help please?
Itâs as it says, gRPC Web isnât supported.
what do you mean?
we canât use the gRPC from flutter - web? streamserverEvents ?
gRPC Web isnât natively supported as web clients are not able to communicate directly with gRPC endpoints, it required an Envoy Proxy to forward the gRPC Web Requests to native gRPC endpoints.
We had read it. But you wrote
we instead recommended using ServiceStack HTTP JSON Services, made possible since ServiceStackâs gRPC Service implementations are also made available over REST-ful HTTP APIs
How we should do it? an example?
That just says to use normal HTTP/Service Clients to call the ServiceStack APIs over HTTP/JSON as-is standard for API Requests from browsers.
We want streamserverEvents with gRPC How to suceed it ? only with anEnvoy Proxy ? an example of that? or we should search the internet?
For Websites you would need to go through a gRPC Web Proxy like Envoy Proxy, though Iâve never tried using it myself, essentially all Websites are going to call HTTP APIs instead.