Hey guys,
I wrote a GrpcService Class:
using System.Net.Http;
using System.Threading.Tasks;
using Grpc.Core;
using Nimbus.Core.Grpc;
using Nimbus.Core.Grpc.WebApi;
using Grpc.Net.Client;
using Grpc.Net.Client.Web;
using FileContentResponse;
public class GrpcService
{
private readonly GrpcChannel _channel;
private const string PRODUCTION_SERVER_URL = "https://api.xxxxxx.com";
public GrpcService(string token)
{
_channel = CreateAuthenticatedChannel(PRODUCTION_SERVER_URL, token);
}
private GrpcChannel CreateAuthenticatedChannel(string address, string token)
{
var credentials = CallCredentials.FromInterceptor((_, metadata) =>
{
if (!string.IsNullOrEmpty(token))
{
metadata.Add("Authorization", $"Bearer {token}");
}
return Task.CompletedTask;
});
var channel = GrpcChannel.ForAddress(address, new GrpcChannelOptions
{
HttpHandler = new GrpcWebHandler(new HttpClientHandler()),
Credentials = ChannelCredentials.Create(new SslCredentials(), credentials),
MaxReceiveMessageSize = 1024 * 1024 * 50, // Set the maximum message size to 50 MB
MaxSendMessageSize = 1024 * 1024 * 50 // Set the maximum message size to 50 MB
});
return channel;
}
public FileContentResponse GetFileContentById(string id)
{
id = RemoveFilesSubstring(id);
var _filesServiceClient = new FilesService.FilesServiceClient(_channel);
var request = new IdRequest
{
Id = id
};
return _filesServiceClient.GetFileContentById(request);
}
private string RemoveFilesSubstring(string input)
{
int index = input.IndexOf("/files/");
return index >= 0 ? input.Substring(index + "/files/".Length) : input;
}
private void OnDisable() {
_channel.ShutdownAsync().Wait();
}
}
I have successfully get response from my server using this class at the Editor level, but when I build I get the following error:
Grpc.Core.RpcException: Status(StatusCode="Internal", Detail="Error starting gRPC call. DllNotFoundException: Unable to load DLL 'libc'. Tried the load the following dynamic libraries: ", DebugException="System.DllNotFoundException: Unable to load DLL 'libc'. Tried the load the following dynamic libraries:
")
I could not find any information or documentation regarding GRPC and WebGL…
Any Ideas?