diff --git a/deps/amqp_client/include/amqp_client.hrl b/deps/amqp_client/include/amqp_client.hrl index ef37297f50..0dc2eaed98 100644 --- a/deps/amqp_client/include/amqp_client.hrl +++ b/deps/amqp_client/include/amqp_client.hrl @@ -33,6 +33,7 @@ channel_max, heartbeat, driver, + port, channels = dict:new() }). -record(channel_state, {number, diff --git a/deps/amqp_client/src/amqp_connection.erl b/deps/amqp_client/src/amqp_connection.erl index 84ad8da196..61f6dd83a6 100644 --- a/deps/amqp_client/src/amqp_connection.erl +++ b/deps/amqp_client/src/amqp_connection.erl @@ -33,8 +33,8 @@ -export([init/1, terminate/2, code_change/3, handle_call/3, handle_cast/2, handle_info/2]). -export([open_channel/1, open_channel/3]). --export([start/2, start/3, start/4, close/2]). --export([start_link/2, start_link/3, start_link/4]). +-export([start/2, start/4, start/5, close/2]). +-export([start_link/2, start_link/4, start_link/5]). %%--------------------------------------------------------------------------- %% AMQP Connection API Methods @@ -48,31 +48,32 @@ start(User, Password, ProcLink) when is_boolean(ProcLink) -> password = Password, vhostpath = <<"/">>}, {ok, Pid} = start_internal(InitialState, amqp_direct_driver, ProcLink), - Pid; + Pid. %% Starts a networked conection to a remote AMQP server. -start(User, Password, Host) -> - start(User, Password, Host, <<"/">>, false). +start(User, Password, Host, Port) -> + start(User, Password, Host, Port, <<"/">>, false). -start(User, Password, Host, VHost) -> - start(User, Password, Host, VHost, false). +start(User, Password, Host, Port, VHost) -> + start(User, Password, Host, Port, VHost, false). -start(User, Password, Host, VHost, ProcLink) -> +start(User, Password, Host, Port, VHost, ProcLink) -> InitialState = #connection_state{username = User, password = Password, serverhost = Host, - vhostpath = VHost}, + vhostpath = VHost, + port = Port}, {ok, Pid} = start_internal(InitialState, amqp_network_driver, ProcLink), Pid. start_link(User, Password) -> start(User, Password, true). -start_link(User, Password, Host) -> - start(User, Password, Host, <<"/">>, true). +start_link(User, Password, Host, Port) -> + start(User, Password, Host, Port, <<"/">>, true). -start_link(User, Password, Host, VHost) -> - start(User, Password, Host, VHost, true). +start_link(User, Password, Host, Port, VHost) -> + start(User, Password, Host, Port, VHost, true). start_internal(InitialState, Driver, _Link = true) when is_atom(Driver) -> gen_server:start_link(?MODULE, [InitialState, Driver], []); diff --git a/deps/amqp_client/src/amqp_network_driver.erl b/deps/amqp_client/src/amqp_network_driver.erl index b5a98a7346..a5dce2ea08 100644 --- a/deps/amqp_client/src/amqp_network_driver.erl +++ b/deps/amqp_client/src/amqp_network_driver.erl @@ -40,8 +40,8 @@ % Driver API Methods %--------------------------------------------------------------------------- -handshake(State = #connection_state{serverhost = Host}) -> - case gen_tcp:connect(Host, 5672, [binary, {packet, 0}, {active, false}, +handshake(State = #connection_state{serverhost = Host, port = Port}) -> + case gen_tcp:connect(Host, Port, [binary, {packet, 0}, {active, false}, {nodelay, true}]) of {ok, Sock} -> ok = gen_tcp:send(Sock, amqp_util:protocol_header()), diff --git a/deps/amqp_client/src/lib_amqp.erl b/deps/amqp_client/src/lib_amqp.erl index b9c611c2a3..5cf8c4df0c 100644 --- a/deps/amqp_client/src/lib_amqp.erl +++ b/deps/amqp_client/src/lib_amqp.erl @@ -35,7 +35,10 @@ start_connection() -> amqp_connection:start("guest", "guest"). start_connection(Host) -> - amqp_connection:start("guest", "guest", Host). + start_connection(Host, ?PROTOCOL_PORT). + +start_connection(Host, Port) -> + amqp_connection:start("guest", "guest", Host, Port). start_channel(Connection) -> amqp_connection:open_channel(Connection). diff --git a/deps/amqp_client/test/direct_client_SUITE.erl b/deps/amqp_client/test/direct_client_SUITE.erl index fb62e36b0b..ba9f861647 100644 --- a/deps/amqp_client/test/direct_client_SUITE.erl +++ b/deps/amqp_client/test/direct_client_SUITE.erl @@ -81,7 +81,7 @@ hard_error_test() -> %%--------------------------------------------------------------------------- new_connection() -> - amqp_connection:start("guest", "guest"). + lib_amqp:start_connection(). test_coverage() -> rabbit_misc:enable_cover(), diff --git a/deps/amqp_client/test/network_client_SUITE.erl b/deps/amqp_client/test/network_client_SUITE.erl index 04b35b378e..328c9789d5 100644 --- a/deps/amqp_client/test/network_client_SUITE.erl +++ b/deps/amqp_client/test/network_client_SUITE.erl @@ -78,7 +78,7 @@ hard_error_test() -> %% Common Functions new_connection() -> - amqp_connection:start("guest", "guest", "localhost"). + lib_amqp:start_connection("localhost"). test_coverage() -> rabbit_misc:enable_cover(),