Server application won't bind to ports on IP address other than my internal ones
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 herehttps://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: linkhttps://github.com/boostorg/beast/blob/develop/example/http/server/async/htt...; this link for the client: linkhttps://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: // 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.
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
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
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
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
On 7/01/2019 16:58, Richard Hodges wrote:
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.
If you're running it on a home (or small office) network, then it is typically your Internet router which actually "has" the external IP; you will need to configure port forwarding in this device to map a port from the external IP to a port on an internal-network IP. Bear in mind that your ISP may have restrictions against (and might block, especially if they are doing another layer of NAT) servers hosted in a home network -- especially in-development ones; and of course there are security concerns with doing so as well. And home external IPs are dynamic, so will change from time to time, making them awkward to use long-term.
I did set up port forwarding on my router for the port I wanted to use. But yeah, I noticed that my external IP changed. My 192.168.x.x IP address is static now, but the external one is still dynamic. The server doesn't stop on my machine, it stops on machines it's downloaded to. And Heroku has to give it the SIGKILL signal after a while because it won't bind to any ports.
If you guys haven't already, I'd like to ask you to read my app's source code. Especially the C++ code. And please also actually get the code and try to run it (though for that you'll need Jinja2Cpp and Nlohmann/JSON and also a Google Maps API Key and currencylayer.com API access key). I need some help in debugging the networking code. I also opened an issue about this ten days on the Boost.Asio GitHub, the link for which is: https://github.com/boostorg/asio/issues/184 . The link to my app's code on GitHub is there, as well as the links to the Boost.Beast example code that I used (note: I didn't write the networking code myself; I just used the examples given on Beast's GitHub repository and extended it to also handle POST requests).
If there's any info you guys need that I haven't given yet, let me know and I'll give it.
[https://avatars0.githubusercontent.com/u/18173932?s=400&v=4]https://github.com/boostorg/asio/issues/184
Server application won't bind to ports on IP address other than my internal ones · Issue #184 · boostorg/asiohttps://github.com/boostorg/asio/issues/184
As the title says, my server application 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 ...
github.com
________________________________
From: Osman Zakir
On Thu, 10 Jan 2019 at 12:15, Osman Zakir via Boost-users < boost-users@lists.boost.org> wrote:
If you guys haven't already, I'd like to ask you to read my app's source code. Especially the C++ code. And please also actually get the code and try to run it (though for that you'll need Jinja2Cpp and Nlohmann/JSON and also a Google Maps API Key and currencylayer.com API access key). I need some help in debugging the networking code. I also opened an issue about this ten days on the Boost.Asio GitHub, the link for which is: https://github.com/boostorg/asio/issues/184 . The link to my app's code on GitHub is there, as well as the links to the Boost.Beast example code that I used (note: I didn't write the networking code myself; I just used the examples given on Beast's GitHub repository and extended it to also handle POST requests).
If there's any info you guys need that I haven't given yet, let me know and I'll give it.
You're kiddin' right? You are actually asking [some pretty busy] people to [get acquainted with, and] debug your code for you, for free, I presume. Iff you have a minimal example exposing you're problem, maybe some help might come your way, but you're already sighting a gazillion dependencies, the problem could be anywhere [but most probably in your own code, look there, check invariants, assumptions you make and re-read docs pertaining to your dependencies]. You write: "... I just used the examples given on Beast's GitHub repository and extended it to also handle POST requests)", that sounds like a likely candidate [the "just" doesn't sound right in my ear]. degski -- *“If something cannot go on forever, it will stop" - Herbert Stein*
participants (5)
-
degski
-
Gavin Lambert
-
Geert Martin Ijewski
-
Osman Zakir
-
Richard Hodges