aws / aws-iot-device-sdk-js-v2

Next generation AWS IoT Client SDK for Node.js using the AWS Common Runtime
Apache License 2.0
217 stars 97 forks source link

Browser disconnects #418

Closed thdxr closed 1 year ago

thdxr commented 1 year ago

Describe the bug

When using the SDK in the browser it eventually throws a CrtError. Reconnect attempts are made but fail with the same error. Refreshing the page fixes it.

Is there something about the configuration that expires?

Expected Behavior

n/a

Current Behavior

n/a

Reproduction Steps

n/a

Possible Solution

No response

Additional Information/Context

No response

SDK version used

1.14.0

Environment details (OS name and version, etc.)

browser

bretambrose commented 1 year ago

What is the error? What is the timeframe? Do you have a minimal sample that reproduces it? How are you sourcing credentials? The more information you provide, the more likely it is that we can dig into the problem.

github-actions[bot] commented 1 year ago

Greetings! It looks like this issue hasn’t been active in longer than a week. We encourage you to check if this is still an issue in the latest release. Because it has been longer than a week since the last update on this, and in the absence of more information, we will be closing this issue soon. If you find that this is still a problem, please feel free to provide a comment or add an upvote to prevent automatic closure, or if the issue is already closed, please feel free to open a new one.

thdxr commented 1 year ago

This is my configuration - using a custom authorizer

      const config = iot.AwsIotMqttConnectionConfigBuilder.new_with_websockets()
        .with_clean_session(true)
        .with_client_id("client_" + createId())
        .with_endpoint(url)
        .with_custom_authorizer(
          "",
          <url>,
          "",
          <token>
        )
        .with_keep_alive_seconds(30)
        .build();

i've tried to notice any pattern but i cannot. it seems to disconnect randomly and a reconnect will fail unless i create the whole client again

logging the error in .on("interrupt") just gives a -1 instead of an error

bretambrose commented 1 year ago

What happens if you increase keep alive significantly? What browser are you using? Safari is notorious for throttling JS execution for backgrounded tabs so severely that keep alive exchanges get completely broken and the client becomes unusable until foregrounded.

thdxr commented 1 year ago

good idea - this is chrome on linux but we've seen this issue across every platform

when you say increase keep alive do you mean make it a larger number? or make it a smaller number

bretambrose commented 1 year ago

Try bumping it up to something like 1200

github-actions[bot] commented 1 year ago

Greetings! It looks like this issue hasn’t been active in longer than a week. We encourage you to check if this is still an issue in the latest release. Because it has been longer than a week since the last update on this, and in the absence of more information, we will be closing this issue soon. If you find that this is still a problem, please feel free to provide a comment or add an upvote to prevent automatic closure, or if the issue is already closed, please feel free to open a new one.