Closed MelbourneDeveloper closed 3 years ago
@MelbourneDeveloper please notice that documentation for ClientChannel
constructor is quite explicit in saying that the first parameter is host
not a uri.
You are looking for something like this:
ClientChannel(
serverHostname,
port: serverPort, // if different from defaults
options: ChannelOptions(
credentials: const ChannelCredentials.secure(), // to use HTTPS
codecRegistry:
CodecRegistry(codecs: const [GzipCodec(), IdentityCodec()]),
));
@mraleph isn't secure the default? I tried without any arguments and it didn't work.
@mraleph I tried this just now:
final channel = ClientChannel(
"https://[URL]",
options: ChannelOptions(
credentials: const ChannelCredentials.secure(), // to use HTTPS
codecRegistry:
CodecRegistry(codecs: const [GzipCodec(), IdentityCodec()]),
));
And, I get the same error.
Note that I have to add this ignore:
// ignore_for_file: avoid_redundant_argument_values
@mraleph why did you close this? I'm still getting the error despite using your code.
Please reopen, or I will need to create a new issue.
Oh, yeah. credentials
are secure by default. You don't need that.
"https://[URL]",
But this you need to fix. This parameter should just be a host name as I have said. Not a uri.
@mraleph got it! Thank. That's awesome.
This parameter should just be a host name as I have said. Not a uri
This is not consistent with other platforms. On .NET you use a uri.
This is not consistent with other platforms. On .NET you use a uri.
Yeah, we seem to have departed from what is described in https://github.com/grpc/grpc/blob/master/doc/naming.md for unclear reasons. I don't know why, maybe original implementors did not see that document.
> lookup(String host, {InternetAddressType type: InternetAddressType.any}) { return _IOService._dispatch(_IOService.socketLookup, [host, type._value]) .then((response) { if (isErrorResponse(response)) { throw createError(response, "Failed host lookup: '$host'"); } return [ for (var result in response.skip(1)) _InternetAddress(InternetAddressType._from(result[0]), result[1], host, result[2], result[3]) ]; }); } ``` ![image](https://user-images.githubusercontent.com/16697547/125911363-c2cd68ca-5b34-477e-9ddb-62db856ee07b.png)