michaelwoods / onstar2mqtt

OnStarJS wrapper for MQTT
MIT License
107 stars 40 forks source link

"ONS-216" after running for a while - rate limiting? #291

Closed mattdsteele closed 1 year ago

mattdsteele commented 1 year ago

Hi, this is a great project!

I'm wondering if I'm getting rate limited or have another throttle applied? Have you seen anything similar?

I setup the docker-compose project as specified in the README. About 12 hours after starting, I begin to see errors like this in the console:

info: Requesting diagnostics
error: Error {"error":{"message":"Command Failure","request":{"body":"{}","contentType":"application/json; charset=UTF-8","headers":{},"method":0,"url":"https://api.gm.com/api/v1/account/vehicles/VID/requests/41951679867"},"response":{"data":{"commandResponse":{"body":{"error":{"code":"ONS-216","description":"Unable to establish packet session to the vehicle"}},"completionTime":"2023-07-04T01:40:39.020Z","requestTime":"2023-07-04T01:39:38.555Z","status":"failure","type":"diagnostics","url":"https://api.gm.com/api/v1/account/vehicles/VID/requests/41951679867"}},"headers":{"connection":"keep-alive","content-type":"application/json;charset=UTF-8","date":"Tue, 04 Jul 2023 01:40:41 GMT","request-context":"appId=cid-v1:b7e19842-5b19-4b47-a9cf-85cc6e87a746","transfer-encoding":"chunked"},"status":200,"statusText":"OK"},"stack":"Error: Command Failure\n    at RequestService.<anonymous> (/app/node_modules/onstarjs/dist/index.cjs:558:35)\n    at Generator.next (<anonymous>)\n    at fulfilled (/app/node_modules/onstarjs/dist/index.cjs:26:58)\n    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)"}}

The error payload pulled out:

{
  "error": {
    "code": "ONS-216",
    "description": "Unable to establish packet session to the vehicle"
  }
}

I also noticed I can't refresh data in the myChevrolet app on my device; which makes me think my account is being rate limited, or has some other restriction placed on it. I've stopped the container for now and will try again tomorrow.

Have you seen anything similar?

BigThunderSR commented 1 year ago

Please see the end of this thread for an explanation - https://github.com/michaelwoods/onstar2mqtt/issues/133

mattdsteele commented 1 year ago

Thank you! I’m trying to recall when I last started the vehicle, but I’ll try starting it up tomorrow to confirm the behavior, and will reopen if I see anything different.

BigThunderSR commented 1 year ago

This is quite normal. You get about 5 - 6 queries after the engine is turned off and you will not get any additional responses until the next time the engine is started up and kept running for at least a couple of minutes. I've sometimes had to go as much as 5 - 10 minutes before the car can be queried again. It seems to be a safety mechanism to prevent the car battery from getting run down to the point of not being able to start the vehicle.

wied03 commented 1 year ago

@BigThunderSR do you know if the myChevroletApp exhibits the same problem? I haven't been able to test recently since the car is in use a lot and getting started anyways.

BigThunderSR commented 1 year ago

@BigThunderSR do you know if the myChevroletApp exhibits the same problem? I haven't been able to test recently since the car is in use a lot and getting started anyways.

You can't forcefully refresh the MyChevrolet app, so there's no 1:1 comparison. If you try the refresh too often though the API, even the MyChevrolet app is eventually unable to send remote commands to the car.

wied03 commented 1 year ago

Does the update portion of the charging modal in the my chevy app not do the same thing?

BigThunderSR commented 1 year ago

Does the update portion of the charging modal in the my chevy app not do the same thing?

Both my vehicles are ICE, so I have no way to compare yours.

wied03 commented 1 year ago

I thought maybe the chevy app does a subset of diagnostics with its "charging update" refresh so I tried https://github.com/wied03/onstar2mqtt/blob/main/src/index.js#L128 but eventually this also started ONS-216'ing.