connect to AWS IoT using web socket with Cognito authenticated users : <p>I'm trying to connect to AWS IoT using web socket from the browser.</p>

<p>I've tried this example:
<a href="https://github.com/awslabs/aws-iot-examples/tree/master/mqttSample" rel="noreferrer">https://github.com/awslabs/aws-iot-examples/tree/master/mqttSample</a> </p>

<p>And another one a little bit modfied so it can be used with Cognito Identity pool logged users.
<a href="https://github.com/dwyl/learn-aws-iot/blob/master/src/js/utils/request.js#L27" rel="noreferrer">https://github.com/dwyl/learn-aws-iot/blob/master/src/js/utils/request.js#L27</a> </p>

<p>I can successfully connect if I use a IAM user with a valid IoT policy, but if I use the user credentials, I receive a "101 Switching Protocols" response but then it gets closed.</p>

<p>The IAM role associated with the authenticated user is correct, and I can sign requests and perform other private operations like calling APIG endpoints. Also the socket connection does not respond with 403. So it's likely not a permissions problem.</p>

<p>What else could it be?</p>
