Skip to content

Commit bc51b8a

Browse files
authored
Greengrass china endpoint (#276)
* Temporary fix for connection with greengrass china endpoint * replace '-' with '.' * allow gg server name to be passed as optional parameter * move gg server to config * update comments for discovery client config * fix formating as suggested in clang-format lint * fix format * fix formatting again
1 parent 75adba3 commit bc51b8a

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

discovery/include/aws/discovery/DiscoveryClient.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ namespace Aws
4545

4646
/**
4747
* The value of the Aws region to connect to.
48-
* Required.
48+
* Optional. (mutually exclusive with ggServerName)
4949
*/
5050
Crt::String Region;
5151

@@ -59,6 +59,12 @@ namespace Aws
5959
* Optional.
6060
*/
6161
Crt::Optional<Crt::Http::HttpClientConnectionProxyOptions> ProxyOptions;
62+
63+
/** The full string of the greengrass server endpoint that you want to connect to.
64+
* Defaults to this over using Region to connect to server
65+
* Optional. (mutually exclusive with ggServerName)
66+
*/
67+
Crt::Optional<Crt::String> ggServerName;
6268
};
6369

6470
class AWS_DISCOVERY_API DiscoveryClient final

discovery/source/DiscoveryClient.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ namespace Aws
1515
namespace Discovery
1616
{
1717
DiscoveryClientConfig::DiscoveryClientConfig() noexcept
18-
: Bootstrap(nullptr), TlsContext(), SocketOptions(), Region(), MaxConnections(2), ProxyOptions()
18+
: Bootstrap(nullptr), TlsContext(), SocketOptions(), Region(), MaxConnections(2), ProxyOptions(),
19+
ggServerName()
1920
{
2021
}
2122

@@ -29,7 +30,16 @@ namespace Aws
2930
m_allocator = allocator;
3031

3132
Crt::StringStream ss;
32-
ss << "greengrass-ats.iot." << clientConfig.Region << ".amazonaws.com";
33+
34+
// Fix for connection with china endpoint
35+
if (clientConfig.ggServerName)
36+
{
37+
ss << *clientConfig.ggServerName;
38+
}
39+
else
40+
{
41+
ss << "greengrass-ats.iot." << clientConfig.Region << ".amazonaws.com";
42+
}
3343

3444
Crt::Io::TlsConnectionOptions tlsConnectionOptions = clientConfig.TlsContext->NewConnectionOptions();
3545
uint16_t port = 443;

0 commit comments

Comments
 (0)