Im having some problems deploying my REST api written in C++ on an EC2 instance.
specifically, in my code I do the following:
server.setEndpoint("http://ec2-18-135-114-10.eu-west-2.compute.amazonaws.com:6502");
Which calls the function (a wrapper for the cpprestsdk):
void BasicController::setEndpoint(const std::string & value) {
uri endpointURI(value);
uri_builder endpointBuilder;
endpointBuilder.set_scheme(endpointURI.scheme());
if (endpointURI.host() == "host_auto_ip4") {
endpointBuilder.set_host(NetworkUtils::hostIP4());
}
else if (endpointURI.host() == "host_auto_ip6") {
endpointBuilder.set_host(NetworkUtils::hostIP6());
}
endpointBuilder.set_port(endpointURI.port());
endpointBuilder.set_path(endpointURI.path());
listener = http_listener(endpointBuilder.to_uri());
}
However, I receive the exception `URI Must contain a host name'
Ok, so I try it again with an elastic public IPv4 address:
server.setEndpoint("http://18.135.114.10:6502/");
Again, I get the same error - no host name.
The only case I can get working is on local host, which looks like
server.setEndpoint("http://127.0.1.1:6502:6502/");
Note, this file shows how the exception arises from the cpprestsdk library https://github.com/microsoft/cpprestsdk/blob/master/Release/src/http/client/http_client.cpp
This is probably a very silly question, so I appreciate an kind person giving their help