Skip to content

fix(iot-dev): Fix connection status reporting CONNECTED before all SDK states are CONNECTED#1355

Merged
timtay-microsoft merged 2 commits intomasterfrom
timtay/connectionStatus
Sep 10, 2021
Merged

fix(iot-dev): Fix connection status reporting CONNECTED before all SDK states are CONNECTED#1355
timtay-microsoft merged 2 commits intomasterfrom
timtay/connectionStatus

Conversation

@timtay-microsoft
Copy link
Copy Markdown
Member

We were executing user facing callbacks with CONNECTED before we were executing SDK facing callbacks with the same state. As a result, users would try to do something like send telemetry as soon as CONNECTED state callback executes only to see an error saying that the deviceIO layer wasn't CONNECTED yet, too.

The solution is to make sure all SDK facing state callbacks are executed before user facing state callbacks are executed

#1348

…K states are CONNECTED

We were executing user facing callbacks with CONNECTED before we were executing SDK facing callbacks with the same state. As a result, users would try to do something like send telemetry as soon as CONNECTED state callback executes only to see an error saying that the deviceIO layer wasn't CONNECTED yet, too.

The solution is to make sure all SDK facing state callbacks are executed before user facing callbacks are executed
this.multiplexingStateCallback.execute(newConnectionStatus, reason, throwable, this.multiplexingStateCallbackContext);
}

this.deviceIOConnectionStatusChangeCallback.execute(newConnectionStatus, reason, throwable, null);
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The user facing state callbacks were above this SDK facing state callback previously. Now this SDK facing state callback executes first

// That will then execute the onConnectionEstablished callback on this same listener. Because of that,
// there is no listener callback to execute here for non-multiplexing cases.
this.listener.onMultiplexedDeviceSessionEstablished(this.connectionId, deviceId);
}
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found this bug while investigating this issue. We shouldn't have been calling "onMultiplexedDeviceSessionEstablished" when not multiplexing. It resulted in the SDK making multiple internal connection state updates when only one should have happened.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This bug shouldn't have any meaningful impact on a user, but it did make debugging the connection state reporting confusing

@timtay-microsoft
Copy link
Copy Markdown
Member Author

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 4 pipeline(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants