Open Nikola-Milovic opened 1 year ago
Identity had to have the policy and not the authenticated user. This fixed the issue
Edit: I'll leave this open as a question on how to grant access to authenticated users without having to have a separate endpoint to handle adding the policy for identity. Maintainers please close this, I'll leave it open for visibility. As https://github.com/aws-amplify/amplify-js/issues/749 left unanswered and I couldn't find the answer anywhere. If there is no way around it, any tips on how to implement it? As identities are temporary, how should I approach expiration and such
Hi @Nikola-Milovic, did you get this issue resolved on your side? I am experiencing similar issue.
The comment I made is the fix, basically you need the policy on the identity itself. But I have no way of easily automating this, nor do I have an idea on why my setup with Authenticated role wasn't working.
@Nikola-Milovic, Are you referring to the identity ID of the user or the Identity pool ID?
@Julz-afk Identity of the authenticated user, I think attaching it to Identity Pool doesn't work. You can try and please let me know
Yeah I have tried using the Auth user ID and also the pool ID, both not working on my side, still getting this error: connecting then connection disrupted. Then this error pops up: MqttOverWSProvider - Error forming connection Error: AMQJS0011E
@Julz-afk follow the guide in their docs, if you attach the policy manually it works
Got it up and running on my side, think I missed a step somewhere with the policy and identity stuff.
Also in nodejs applications WebSockets is missing as in never imported and is expected on the global.
@Julz-afk Identity of the authenticated user, I think attaching it to Identity Pool doesn't work. You can try and please let me know
Thanks , that helped, you are right
Where can I find that Identity Id ? I'm facing the same issue and nothing seems to fix it. Maybe I didn't understand the Policies and Identities.
Btw I'm using NextJs, don't know if it's supposed to work with it.
I confirm, in my case i didn't created and added the policy to the user after authentification , i recommand reading this section of amplify documentation and understand it very well : [https://docs.amplify.aws/javascript/build-a-backend/more-features/pubsub/set-up-pubsub/] thank you @Nikola-Milovic for the hint.
Is this issue happening on version 5 only?
Before opening, please confirm:
JavaScript Framework
React
Amplify APIs
PubSub
Amplify Categories
auth
Environment information
Describe the bug
When trying to connect to AWS IoT with Amplify and Pub/Sub I am stuck in the
ConnectionDisturbed
->Connection
loopExpected behavior
It should be in connected state and stay in it
Reproduction steps
Have my CDK configuration with my
amplify.ts
fileCode Snippet
My setup is as follows
amplify.ts
file that I import in the entrypoint to my appAll of my env variables are correct, I also have
geo
setup, and its working.The endpoint also matches the one in
IoT Core
->Settings
.This is my endpoint
wss://a3ri7xxxxxxxxx-ats.iot.eu-central-1.amazonaws.com/mqtt
I receive no errors other than the connection being disrupted. If I try to
publish
I get[undefined]
back without any errors.I am not using the
CLI
but my own CDK and I have thisSo my
Authenticated
users should have access to the IoT.Log output
Additional information
There was an issue that mentions something related to access to Pub/Sub IoT but it was closed and not answered https://github.com/aws-amplify/amplify-js/issues/749, doesn't seem to be the issue I am experiencing
Also if I try to connect over plain MQTT instead of websockets or with HTTPS, then I am stuck in
Connecting
state.Not sure how to debug without any error logs, not sure what could cause such behaviour.
My only guess is that I am misunderstanding roles and users and that the
Policy
I gave to my authenticated users is in fact not doing what I expect it to. As in the docs its statedWhile I am not attaching it to Cognito Identity.