The network stack can only bind an acceptor (underneath it's a socket) to an address currently mapped into the IP network stack of the machine, docker container or VM - depending on where you are running it. On many hosting services, the external (visible to the world) IP address is not actually on the same machine on which you are running your application. There is usually a facility to map/route the external IP address and port onto the private IP address of your application server. This is not a failure of ASIO, just a consequence of the architectural deployment choices of you and/or your hosting company. On a separate note, the fact that your server stops after a while seems unrelated. It will be due to a logic error in your code. On Mon, 7 Jan 2019 at 02:48, Osman Zakir via Boost-users < boost-users@lists.boost.org> wrote:
It doesn't bind to any IP address that Heroku tries to bind it to, when I try to deploy it there with a Dockerfile, either. And whenever someone downloads the app and tries to run it, it won't bind to any port they try to bind it to either (and in this case it applies to internal IP addresses too). This is a huge problem. ------------------------------ *From:* Boost-users
on behalf of Geert Martin Ijewski via Boost-users *Sent:* Monday, January 7, 2019 12:41 AM *To:* boost-users@lists.boost.org *Cc:* Geert Martin Ijewski *Subject:* Re: [Boost-users] Server application won't bind to ports on IP address other than my internal ones On 1/6/19 7:28 PM, Osman Zakir via Boost-users wrote:
I have a server application that I wrote. It currently doesn't bind to any ports on any IP address other than my computer's internal IP addresses (the localhost and 192.168.x.x ones). The application is the one whose source code is on GitHub here https://github.com/DragonOsman/currency_converter/.
I used the asynchronous server and client examples from the Boost.Beast GitHub repository for the networking code (this link for the server: link < https://github.com/boostorg/beast/blob/develop/example/http/server/async/htt... ; this link for the client: link < https://github.com/boostorg/beast/blob/develop/example/http/client/async/htt... ). But when I run it using my external IP address, I get the error documented on lines 471 and 472:
Your computer probably is behind the NAT (Network Address Translation) of your ISP -- so it has no knowledge of your external IP. You can try that by running `ip addr` or `ipconfig` in the terminal (For windows: Press Win+R and type cmd, for mac: search for Terminal, if you use linux you should know how to start it)
Most likely it will not show you your external IP. Almost all internet service providers will not allocate you a static IP but instead use NAT to get around the limitations of IPv4. That is expected -- you probably have to debug it locally with your local IP and then buy a VPS to make your application available to the general internet.
// Bind to the server address acceptor_.bind(endpoint, ec); if (ec) { std::cerr << "Lines 471 and 472:\n"; fail(ec, "bind"); return; }
with the error itself being:
|bind: The requested address is not valid in its context |
And I've heard from whoever has tried to download and then run the server application that it just closes on its own after a while. I also tried to deploy it to Heroku as a Docker container before and found that it wouldn't bind to any ports they tried to bind it to and they had to kill it with SIGKILL.
I tried to look for the code for |bind| in Asio, but I don't really know where to look. Some help on that would also be appreciated. I might be able to figure it from reading that code. If I can't, I'll come back
here.
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org https://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org https://lists.boost.org/mailman/listinfo.cgi/boost-users _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org https://lists.boost.org/mailman/listinfo.cgi/boost-users