-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support multiple http endpoints #1137
Conversation
plugins/http_plugin/include/eosio/http_plugin/beast_http_session.hpp
Outdated
Show resolved
Hide resolved
plugins/http_plugin/include/eosio/http_plugin/beast_http_session.hpp
Outdated
Show resolved
Hide resolved
@@ -241,6 +241,10 @@ add_test(NAME plugin_http_api_test COMMAND tests/plugin_http_api_test.py WORKING | |||
set_tests_properties(plugin_http_api_test PROPERTIES TIMEOUT 50) | |||
set_property(TEST plugin_http_api_test PROPERTY LABELS nonparallelizable_tests) | |||
|
|||
add_test(NAME plugin_http_category_api_test COMMAND tests/plugin_http_api_test.py WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) | |||
set_tests_properties(plugin_http_category_api_test PROPERTIES TIMEOUT 50 ENVIRONMENT "PLUGIN_HTTP_TEST_CATEGORY=ON") | |||
set_property(TEST plugin_http_category_api_test PROPERTY LABELS nonparallelizable_tests) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How is different then the existing plugin_http_api_test
, no new args are passed to the test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see this passes an ENVIRONMENT variable. Can we change that to an argument to the python test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried several ways and failed. This is the only way that I can think of which doesn't require me to rewrite the entire test.
Tests failing because keosd not launching:
|
plugins/http_plugin/http_plugin.cpp
Outdated
boost::system::error_code ec; | ||
tcp::resolver resolver(plugin_state->thread_pool.get_executor()); | ||
auto endpoints = resolver.resolve(host, port, boost::asio::ip::tcp::resolver::passive, ec); | ||
EOS_ASSERT(!ec, chain::plugin_config_exception, "failed to resolve address: ${msg}", ("msg", ec.message())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just curious, why are we throwing here if the address is incorrect? Where is the intended try/catch block?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe main() should catch it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, should likely not throw from here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like it is only called from is_on_loopback
which is only currently called from plugin_initialize
. However It seems like it would be better for this to only log a warning and return false. Seems like loopback should always be resolvable so unable to resolve likely means not on loopback.
I'm not understanding where we do the |
This PR implements the proposal https://github.com/eosnetworkfoundation/product/blob/main/api-http/proposals/http-plugin.md to support multiple endpoints for http plugins.
APIs are categorized into the following groups:
chain_ro
chain_rw
db_size
net_ro
net_rw
producer_ro
producer_rw
snapshot
trace_api
prometheus
node
User configuration knob
A single
http-category-address
can be used to configure all addresses in command line and ini file. The option can be used multiple times as needed.A single
hostname:port
specification can be used by multiple categories, as of the case for127.0.0.1:8081
in above example. However, two specifications having the same port with different hostname strings are always considered as configuration error regardless whether they can be resolved into the same set of IP addresses. For example, the following configuration are invalid.For the node category, it is NOT user configurable because it will be available for all listened http addresses.
For backward compatibility, the HTTP category facility has to be opted in by specifying
http-server-address = http-category-address
explicitly.When
http-server-address = http-category-address
, all the unspecified categories are considered disabled. In addition,http-server-address = http-category-address
cannot be specified together with a non-emptyunix-socket-path
.All existing configuration options in the http plugin apply to all handlers for all addresses; this includes the
http-threads
option. This means all handlers share the same thread pool.server address format
server address can be in one of the following formats
In the case of the hostname, the IP address is resolved by ARP, ALL resolved addresses will be listened to.
To listen to all interfaces for both IPv4 and IPv6, just use
:8080
. Notice that the behavior of[::]:8080
is dependent on whether the IPv4-mapped IPv6 is enabled in the system.Resolves #965