1
votes

The sendCommandToDevice endpoint seems to be unavailable. I tried sending the command directly from the cloud console on the device page. The notification at the bottom left said, Command sent to device, but the inspector on chrome showed a 503 error. Time of error: 17:46:02 UTC Saturday, 27 October 2018

Request:

Request URL: https://cloudiot.clients6.google.com/v1/projects/<project-id>/locations/<location-name>/registries/<registry-name>/devices/<device-name>/:sendCommandToDevice?key=<removed> Request Method: POST Status Code: 503 Remote Address: 216.58.196.74:443 Referrer Policy: no-referrer-when-downgrade Payload: {binaryData: "eyJ0ZXN0IjoxfQ==", subfolder: ""}

Response:

{ "error": { "code": 503, "message": "The service is currently unavailable.", "status": "UNAVAILABLE" } }

Also, an additional note, sendCommandToDevice is not available in the nodejs client library (34.0.0). I had to do API discovery to have the method available.

2

2 Answers

0
votes

Are you still receiving the 503? I tested this just now and was able to receive messages successfully.

Also, regarding the the lack of availability of Commands features in the client library, Commands is still in Beta and those methods will be available in the client library once it is fully released.

0
votes

This is probably due to

  1. bug in the node library
  2. bug in Google's RPC endpoint
  3. Lack of testing on Google's part

The problem is that subfolder MUST be specified, and MUST not be an empty string.

As I was using this in a Firebase function, I just use the firebase subfolder for any commands being sent that do not have a specific subfolder

const request = {
    name: `${registryName}/devices/${deviceId}`,
    binaryData: Buffer.from(JSON.stringify(commandMessage)).toString("base64"),
    subfolder: 'firebase'
}

Here's functions deps:

  "dependencies": {
    "firebase-admin": "^6.4.0",
    "firebase-functions": "^2.1.0",
    "fs-extra": "^7.0.0",
    "googleapis": "^36.0.0",
  },