Skip to content

WebSocket Connection methods #545

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jan 26, 2024
Merged

WebSocket Connection methods #545

merged 8 commits into from
Jan 26, 2024

Conversation

alfred2g
Copy link
Contributor

@alfred2g alfred2g commented Jan 5, 2024

Readme for samples websocket connection methods

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@@ -4,6 +4,12 @@

This sample makes an MQTT connection via Websockets and then disconnects. On startup, the device connects to the server via Websockets and then disconnects right after. This sample is for reference on connecting via Websockets. This sample demonstrates the most straightforward way to connect via Websockets by querying the AWS credentials for the connection from the device's environment variables or local files.

If you want to use custom auth (or static creds, or basic auth, etc) instead,
Copy link
Contributor

Choose a reason for hiding this comment

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

We should explicitly write that these are websocket with custom auth (and others).

If you want to use custom auth (or static creds, or basic auth, etc) instead,
then you will need to replace part of the sample (connection\_setup function) with a code snippet we provided in its corresponding readme.

* [custom auth](./websocket_connect_custom_auth.md)
Copy link
Contributor

Choose a reason for hiding this comment

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

custom auth and static credentials label should also explicitly be named with websocket included. The links are to the websocket md files but the link text on display could be confusing/misleading.

# Websocket Connect with Custom Authentication

[**Return to main sample list**](../../README.md)

Copy link
Contributor

Choose a reason for hiding this comment

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

Both of these readme should directly reference that the sample being modified is the websocket_connect.py sample.

<summary> (code snipet to replace similar section)</summary>
<pre language="python">
<code>
def connection_setup():
Copy link
Contributor

Choose a reason for hiding this comment

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

there is no def connection_setup() in the websocket_connect.py. connection_setup() is also not called in the main function of websocket_connect.py. Let's change both these snippets to be more descriptive of what is being changed and what it's doing.

e.g. first code snippet, show what is being changed and why
This will parse the command line argument to run the sample for the arguments for connecting to the websocket using a custom authorizer.
code block

cmdData = CommandLineUtils.parse_sample_input_websocket_connect()

cmdData = CommandLineUtils.parse_sample_input_custom_authorizer_connect()
/code block

Secondary code snippet that describes and shows changes in main

Copy link
Contributor

@xiazhvera xiazhvera Jan 11, 2024

Choose a reason for hiding this comment

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

Could we also add remarkable comments to highlight where/what to change in websocket_connect.py .
For example:

################ BEGIN SECTION ###############
## Replace this section to parse different arguments #### 

cmdData = CommandLineUtils.parse_sample_input_custom_authorizer_connect()

################ END SECTION ###############

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no need to, as the user has to just replace the function connection_setup and nothing else

Copy link
Contributor

@xiazhvera xiazhvera Jan 26, 2024

Choose a reason for hiding this comment

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

I didnt find connection_setup() in samples/websocket_connect.py, while I did see it in our cpp samples. Are we missing the update for the python sample?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added

@alfred2g alfred2g requested a review from sbSteveK January 19, 2024 17:05
@alfred2g alfred2g requested a review from xiazhvera January 25, 2024 23:37
Copy link
Contributor

@xiazhvera xiazhvera left a comment

Choose a reason for hiding this comment

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

We probably wanna make sure we have connection_setup for user to replace the codesnip. Other than that, the PR looks good to me.

@alfred2g alfred2g requested a review from xiazhvera January 26, 2024 00:11
cmdUtils.register_command(CommandLineUtils.m_cmd_client_id, "<str>",
"Client ID to use for MQTT connection (optional, default='test-*').",
default="test-" + str(uuid4()))
cmdUtils.register_command(CommandLineUtils.m_cmd_session_token, "<str>", "", default="test-" + str(uuid4()))
Copy link
Contributor

Choose a reason for hiding this comment

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

session token, access key id, and secret access key are missing help definitions. Also, are any of these required for the static credentials connect? If the sample will fail if one is missing, set the required to True if a default isn't provided.

Copy link
Contributor

@sbSteveK sbSteveK left a comment

Choose a reason for hiding this comment

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

Address comments and everything else looks good.

@alfred2g alfred2g merged commit 1a0c4bc into main Jan 26, 2024
@alfred2g alfred2g deleted the connection_methods branch January 26, 2024 18:55
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.

3 participants