Skip to content

Commit

Permalink
Don't let browser choose port in 311 implementation (#514)
Browse files Browse the repository at this point in the history
  • Loading branch information
bretambrose authored Dec 11, 2023
1 parent 7fa94ac commit de6ad72
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/browser/aws_iot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class AwsIotMqttConnectionConfigBuilder {
client_id: '',
host_name: '',
socket_options: new SocketOptions(),
port: 8883,
port: 443,
clean_session: false,
keep_alive: undefined,
will: undefined,
Expand Down
6 changes: 3 additions & 3 deletions lib/browser/ws.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,11 @@ export function create_websocket_url(config: MqttConnectionConfig) {
const day = canonical_day(time);
const query_params = `X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=${signing_config.credentials.aws_access_id}` +
`%2F${day}%2F${signing_config.credentials.aws_region}%2F${signing_config.service}%2Faws4_request&X-Amz-Date=${time}&X-Amz-SignedHeaders=host`;
const url = new URL(`wss://${config.host_name}${path}?${query_params}`);
const url = new URL(`wss://${config.host_name}:${config.port}${path}?${query_params}`);
return sign_url('GET', url, signing_config, time, day);
}
else if (protocol === 'wss-custom-auth') {
return `wss://${config.host_name}/${path}`;
return `wss://${config.host_name}:${config.port}${path}`;
}
throw new URIError(`Invalid protocol requested: ${protocol}`);
}
Expand Down Expand Up @@ -170,7 +170,7 @@ export function create_mqtt5_websocket_url(config: mqtt5.Mqtt5ClientConfig) {
const day = canonical_day(time);
const query_params = `X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=${signingConfig.credentials.aws_access_id}` +
`%2F${day}%2F${region}%2F${signingConfig.service}%2Faws4_request&X-Amz-Date=${time}&X-Amz-SignedHeaders=host`;
const url = new URL(`wss://${config.hostName}${path}?${query_params}`);
const url = new URL(`wss://${config.hostName}:${config.port}${path}?${query_params}`);
return sign_url('GET', url, signingConfig, time, day);

case mqtt5.Mqtt5WebsocketUrlFactoryType.Custom:
Expand Down

0 comments on commit de6ad72

Please sign in to comment.