Boost logo

Boost Users :

Subject: Re: [Boost-users] Server application won't bind to ports on IP address other than my internal ones
From: Geert Martin Ijewski (gm.ijewski_at_[hidden])
Date: 2019-01-06 19:41:25


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/http_server_async.cpp>;
> this link for the client: link
> <https://github.com/boostorg/beast/blob/develop/example/http/client/async/http_client_async.cpp>).
> 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_at_[hidden]
> https://lists.boost.org/mailman/listinfo.cgi/boost-users
>


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net