Using SDK with API behind LetsEncrypt

Hello,

I installed the Chirpstack stack following the GCP guide (https://www.chirpstack.io/project/guides/google-cloud-platform/). The bridge is installed on the gateways.

I did not install the TLS certificates (https://github.com/brocaar/chirpstack-certificates) because everything is on a private network and the only public component is the application server. I secured the access to the application server with LetsEncrypt.

Now I would like to use the javascript SDK to call the API (https://www.npmjs.com/package/@chirpstack/chirpstack-api). I try to get a device with the following snippet:

const grpc = require('grpc');
const nsDeviceService = require('@chirpstack/chirpstack-api/as/external/api/device_grpc_pb');
const { GetDeviceRequest } = require('@chirpstack/chirpstack-api/as/external/api/device_pb');

const deviceServiceClient = new nsDeviceService.DeviceServiceClient(
  '<DOMAIN>',
  grpc.credentials.createSsl(),
);

const metadata = new grpc.Metadata();
metadata.set(
  'authorization',
  'Bearer <API_TOKEN>'
);

const reqArgs = new GetDeviceRequest();
reqArgs.setDevEui("<DEVEUI>");
deviceServiceClient.get(reqArgs, metadata, (error, response) => {
  if (error) {
    console.error(error);
  } else {
    console.log("it works!");
  }
});

I get the following error:

Error: 1 CANCELLED: Received http2 header with status: 404

I get the same error if I add the port number (i.e.: :443).

If I try it using grps.credentials.createInsecure(), I get this error:

Error: 14 UNAVAILABLE: Trying to connect an http1.x server

I am able to call the API using cURL or the swagger page, so I don’t understand why I get this problem.

Could someone please help me?