Questions tagged with AWS IoT Core

Content language: English

Sort by most recent

Browse through the questions and answers listed below or filter and sort to narrow down your results.

Millisecond accuracy in IoT Core LoRaWan message timestamps

Is there any way to enforce millisecond accurate timestamps in the metadata of messages from LoRaWan devices? I have verified that the timestamp generated by my gateway is a unix timestamp in millisecond (eg `1667406503931`), but the JSON timestamp in the metadata I am getting from IoT Core is a string timestamp that only goes to seconds (eg. `2022-11-02T16:23:15Z`). The example with gateway metadata off on [this page of the documentation](https://docs.aws.amazon.com/iot/latest/developerguide/connect-iot-lorawan-uplink-metadata-format.html) has an example of a message with milliseconds in the timestamp, and I am curious how accurate that example is. Currently if I disable gateway metadata in the service profile it will remove the timestamp all-together (the only metadata I get is fcount and fport) so I am wondering if I am missing something or if that example is just wrong. Truncating the milliseconds like this also makes it unclear if the timestamp in the metadata is the time that the Gateway received the message, or if it is the time that the LNS server received the message, is this information also available anywhere? I poked around in the settings and documentation for the Devices, Gateways, Device profiles and Service profiles and was unable to find much regarding timestamps or metadata formatting. Is anyone able to provide any insight into this, or otherwise point me in the right direction?
1
answers
0
votes
45
views
asked 24 days ago

Amplify pubsub subscribe won't work on authenticated user

I have a react app with a very simple page that subscribes to a topic once the page is loaded. I followed the instructions from [HERE](https://docs.amplify.aws/lib/pubsub/getting-started/q/platform/js/) and I've created the cognito user pool and identity pool and assign the correct policies. Also I attached an IoT policy to the Identity Pool Id. I assigned permissions to subscribe to a topic for both, Authenticated and Unauthenticated users Now, I test the pubsub subscribe to topic on a test page when the page loads and there is no Authenticated User, there it loads and subscribes to the topic and receives messages. No problem. But when the user is authenticated and gets into the page, Amplify throws an UNDEFINED error. Any ideas what I should be doing wrong? or where can I look and how to get more information on this error? Below are the debug messages I've got Here is what I have in **index.js** ``` import App from './App'; import { Amplify} from 'aws-amplify'; import { AWSIoTProvider } from '@aws-amplify/pubsub'; mplify.Logger.LOG_LEVEL = 'DEBUG'; Amplify.configure({ Auth: { region: config.cognito.REGION, userPoolId: config.cognito.USER_POOL_ID, identityPoolId: config.cognito.IDENTITY_POOL_ID, userPoolWebClientId: config.cognito.APP_CLIENT_ID, } }); Amplify.addPluggable( new AWSIoTProvider({ aws_pubsub_region: config.iot.REGION, aws_pubsub_endpoint: config.iot.PUBSUB_ENDPOINT, }) ); const root = ReactDOM.createRoot(document.getElementById('root')); root.render(<App />); ``` here is what I have in the test page ``` import {PubSub } from 'aws-amplify'; export default function Space() { let mqttSubscription; useEffect(() => { function subscribeToShadowUpdates() { mqttSubscription = PubSub.subscribe('$aws/things/+/shadow/update/documents').subscribe({ //next: (data) => console.log(JSON.stringify(data, null, 2)), next: (data) => console.log(data), error: (error) => console.log('ERROR: ', error), close: () => console.log('Done'), }); }; subscribeToShadowUpdates(); }, []); useEffect(() => { return () => { mqttSubscription.unsubscribe(); } }, []); return ( <div> Test </div> ) } ``` Logs with UNAUTHENTICATED User ``` ConsoleLogger.ts:125 [DEBUG] 25:29.177 Amplify - amplify config {Auth: {…}, API: {…}} ConsoleLogger.ts:115 [DEBUG] 25:29.177 AuthClass - configure Auth ConsoleLogger.ts:125 [DEBUG] 25:29.177 Parser - parse config (3) [{…}, 'to amplifyconfig', {…}] ConsoleLogger.ts:125 [DEBUG] 25:29.178 Hub - Dispatching to auth with {event: 'configured', data: null, message: 'The Auth category has been configured successfully'} ConsoleLogger.ts:125 [DEBUG] 25:29.178 RestAPI - configure Rest API {opt: {…}} ConsoleLogger.ts:115 [DEBUG] 25:29.178 RestAPI - create Rest API instance ConsoleLogger.ts:125 [DEBUG] 25:29.178 RestClient - API Options {endpoints: Array(1), Auth: {…}} ConsoleLogger.ts:115 [DEBUG] 25:29.179 I18n - configure I18n ConsoleLogger.ts:115 [DEBUG] 25:29.179 I18n - create I18n instance ConsoleLogger.ts:125 [DEBUG] 25:29.179 PubSub - configure PubSub {opt: {…}} ConsoleLogger.ts:125 [DEBUG] 25:29.179 GraphQLAPI - configure GraphQL API {opt: {…}} ConsoleLogger.ts:115 [DEBUG] 25:29.179 GraphQLAPI - create Rest instance ConsoleLogger.ts:125 [DEBUG] 25:29.179 RestClient - API Options {Auth: {…}, endpoints: Array(1)} ConsoleLogger.ts:125 [DEBUG] 25:29.179 RestAPI - configure Rest API {opt: {…}} ConsoleLogger.ts:115 [DEBUG] 25:29.179 RestAPI - create Rest API instance ConsoleLogger.ts:125 [DEBUG] 25:29.179 RestClient - API Options {endpoints: Array(1), Auth: {…}} ConsoleLogger.ts:125 [DEBUG] 25:29.180 GraphQLAPI - configure GraphQL API {opt: {…}} ConsoleLogger.ts:115 [DEBUG] 25:29.180 GraphQLAPI - create Rest instance ConsoleLogger.ts:125 [DEBUG] 25:29.180 RestClient - API Options {Auth: {…}, endpoints: Array(1)} ConsoleLogger.ts:125 [DEBUG] 25:29.181 AbstractPubSubProvider - configure AWSIoTProvider {Auth: {…}, API: {…}, aws_pubsub_region: 'us-east-2', aws_pubsub_endpoint: 'wss://a3e8rmm32eyr8h-ats.iot.us-east-2.amazonaws.com/mqtt', clientId: '72df23de-feed-4a8f-aa8d-80ce14d5160b'} ConsoleLogger.ts:125 [DEBUG] 25:30.377 PubSub - subscribe options undefined ConsoleLogger.ts:125 [DEBUG] 25:30.377 MqttOverWSProvider - Subscribing to topic(s) $aws/things/+/shadow/update/documents ConsoleLogger.ts:115 [DEBUG] 25:30.378 Credentials - getting credentials ConsoleLogger.ts:115 [DEBUG] 25:30.378 Credentials - picking up credentials ConsoleLogger.ts:115 [DEBUG] 25:30.378 Credentials - getting new cred promise ConsoleLogger.ts:115 [DEBUG] 25:30.379 Credentials - checking if credentials exists and not expired ConsoleLogger.ts:115 [DEBUG] 25:30.379 Credentials - need to get a new credential or refresh the existing one ConsoleLogger.ts:115 [DEBUG] 25:30.379 Credentials - no credentials for expiration check ConsoleLogger.ts:115 [DEBUG] 25:30.379 AuthClass - Getting current user credentials ConsoleLogger.ts:115 [DEBUG] 25:30.384 AuthClass - Getting current session ConsoleLogger.ts:115 [DEBUG] 25:30.384 AuthClass - Failed to get user from user pool ConsoleLogger.ts:125 [DEBUG] 25:30.384 AuthClass - Failed to get the current user No current user ConsoleLogger.ts:115 [DEBUG] 25:30.384 AuthClass - getting guest credentials ConsoleLogger.ts:115 [DEBUG] 25:30.384 Credentials - setting credentials for guest ConsoleLogger.ts:125 [DEBUG] 25:30.920 Credentials - Load credentials successfully {identityId: 'us-east-2:xxx', accessKeyId: 'xxxx', secretAccessKey: 'xxx', sessionToken: 'xxx…xxx', expiration: Wed Nov 02 2022 11:25:30 GMT+0100 (Central European Standard Time)} ConsoleLogger.ts:118 [DEBUG] 25:30.924 Signer {region: 'xx-xxx-x', service: 'iotdevicegateway'} ConsoleLogger.ts:125 [DEBUG] 25:30.926 MqttOverWSProvider - Creating new MQTT client 72df23de-feed-4a8f-aa8d-80ce14d5160b ``` Logs with AUTHENTICATED USER ``` [DEBUG] 27:26.427 Credentials - checking if credentials exists and not expired ConsoleLogger.ts:125 [DEBUG] 27:26.427 Credentials - are these credentials expired? {accessKeyId: 'xxx', secretAccessKey: 'xxx', sessionToken: 'xxxxxx', expiration: Wed Nov 02 2022 11:27:22 GMT+0100 (Central European Standard Time), identityId: 'us-east-2:xxxxx', …} ConsoleLogger.ts:115 [DEBUG] 27:26.427 Credentials - credentials not changed and not expired, directly return ConsoleLogger.ts:118 [DEBUG] 27:26.434 Signer {region: 'us-east-2', service: 'iotdevicegateway'} ConsoleLogger.ts:125 [DEBUG] 27:26.436 MqttOverWSProvider - Creating new MQTT client 09db81a1-f3eb-4e70-95fb-d286da21b209 ERROR: {provider: AWSIoTProvider, error: undefined} [DEBUG] 27:26.952 MqttOverWSProvider - Unsubscribing from topic(s) $aws/things/+/shadow/update/documents ``` And this is the JSON in undefined ```` { "provider": { "_config": { "Auth": { "region": "us-east-2", "userPoolId": "us-east-2_xxxx", "identityPoolId": "us-east-2:xxxxx", "userPoolWebClientId": "xxxx" }, "API": { "endpoints": [ { "name": "spaces", "endpoint": "https://xxxxx.execute-api.us-xxx-x.amazonaws.com", "region": "us-xxx-x" } ] }, "aws_pubsub_region": "us-east-2", "aws_pubsub_endpoint": "wss://xxxx-ats.iot.us-xxx-x.amazonaws.com/mqtt", "clientId": "09db81a1-f3eb-4e70-95fb-d286da21b209" }, "_clientsQueue": { "promises": {} }, "connectionStateMonitor": { "_linkedConnectionState": { "networkState": "connected", "connectionState": "disconnected", "intendedConnectionState": "disconnected", "keepAliveState": "healthy" }, "_linkedConnectionStateObservable": {}, "_linkedConnectionStateObserver": { "_subscription": { "_observer": {}, "_state": "ready" } } }, "_topicObservers": {}, "_clientIdObservers": {} } } ```
1
answers
0
votes
19
views
mvp
asked 24 days ago

Code 400, message Bad request version ('18.0} from Network Load Balancer

My problem is that I am in the process of moving from the IoT-Core/Lambda services to a ECS docker doing containing a Mosquitto broker. This is because AWS IoT-Core does not support basic authentication and we really need this to be supported - our IoT devices have very limited resources, so we struggle very much to perform the encryption you require on the IoT-Core service. Now I have setup the docker and implemented the network load balancer, but sometimes (only sometimes) the load balancer fails to handle a simple JSON message. The MQTT message I am sending is always the same, but sometimes the load balancer fails with "code 400, message Bad request version" and other times everything is fine. When I am sending the messages directly to the Containers public IP things are always working. Also when I have the exact same docker running on my localhost and there things are also working fine. So, I think this is a problem caused by the load balancer and I am out of ideas on how solve this? Log from where the load balancer rejets the message: 2022-10-28 06:50:3410.0.0.196 - - [28/Oct/2022 04:50:34] code 400, message Bad request version ('18.0}')8a1c1c7e0e5d4353ac68e974ce4adb99 10.0.0.196 - - [28/Oct/2022 04:50:34] code 400, message Bad request version ('18.0}') 2022-10-28 06:50:3410.0.0.196 - - [28/Oct/2022 04:50:34] "2MQTTÂ< publisherdmrfOOgG5%@2hSV8DOF1nPa*80Ócanister/outgoing{"clientid": "786523DB50583837372E3120FF181243", "elapsedHours": 1, "powerUpCounter": 1, "pressure": 1024, "valveState": 1, "stepPressureTarget": 1000, "rtcTemp": 21.0, "batteryVoltage": 18.0}" 400 -8a1c1c7e0e5d4353ac68e974ce4adb99 10.0.0.196 - - [28/Oct/2022 04:50:34] "2MQTTÂ< publisherdmrfOOgG5%@2hSV8DOF1nPa*80Ócanister/outgoing{"clientid": "786523DB50583837372E3120FF181243", "elapsedHours": 1, "powerUpCounter": 1, "pressure": 1024, "valveState": 1, "stepPressureTarget": 1000, "rtcTemp": 21.0, "batteryVoltage": 18.0}" 400 -
1
answers
0
votes
14
views
asked a month ago