amqp-client 1.1.2 → 1.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: baa9c2034e80f56aa375a7abb7394109d2f4e84e4a4c04ae8bcb053d299d6dcc
4
- data.tar.gz: 7857e1d6ddf96a64df664956da02eac2098fe144a5d2eea1364bd14ba5d41b7c
3
+ metadata.gz: 191cd8053858a46d350a6c89db378058c9c602bde3eadc95ee4ae79b149fb0cf
4
+ data.tar.gz: c322ca75508f8a9566170fa473b562dfe4b4989dc6b1e2baa68408612fe47692
5
5
  SHA512:
6
- metadata.gz: 4deaecc1cdce66be71316e3046c5df0832c20a876ad0d3f5884c6e6313ece2d7fad8262f8ee83daad78500ca411648618642eb551c63279e8b84ec727d1f5633
7
- data.tar.gz: 4136f5ce5c98610361a673f348fd531a93c34c7989275e7858bfc9694d7368adcbd17beb910fae30cd1fceb29163b7411d4ee0dc235f9c655bfdf960a9de4602
6
+ metadata.gz: 7c47bba0271dbd49b603127ac8749bfd85468ea7b0faa97d857eca585cde012094ace144b339a71d24fc4c90dace83f5e562669ae040ddb1eedd54b24eb6a876
7
+ data.tar.gz: 3ecb4641c83020063186fa1ac4413e6e42ae33ecb013eae3d2dcadfa1c30a3943ddf6320561ccb63917376ac23ac908c87f2d7e64abd7508c69c9f1030460e8e
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [1.1.3] - 2021-11-04
4
+
5
+ - Fixed: Reraise SystemcallError in connect so that reconnect works
6
+ - Fixed: Keepalive support in OS X
7
+ - Added: Make keepalive settings configurable (eg. amqp://?keepalive=60:10:3)
8
+
3
9
  ## [1.1.2] - 2021-10-15
4
10
 
5
11
  - Added: Support for JRuby and TruffleRuby
@@ -24,6 +24,7 @@ module AMQP
24
24
  # the smallest of the client's and the broker's values will be used
25
25
  # @option options [Integer] channel_max (2048) Maxium number of channels the client will be allowed to have open.
26
26
  # Maxium allowed is 65_536. The smallest of the client's and the broker's value will be used.
27
+ # @option options [String] keepalive (60:10:3) TCP keepalive setting, 60s idle, 10s interval between probes, 3 probes
27
28
  # @return [Connection]
28
29
  def initialize(uri = "", read_loop_thread: true, **options)
29
30
  uri = URI.parse(uri)
@@ -383,7 +384,8 @@ module AMQP
383
384
  def open_socket(host, port, tls, options)
384
385
  connect_timeout = options.fetch(:connect_timeout, 30).to_i
385
386
  socket = Socket.tcp host, port, connect_timeout: connect_timeout
386
- enable_tcp_keepalive(socket)
387
+ keepalive = options.fetch(:keepalive, "").split(":", 3).map!(&:to_i)
388
+ enable_tcp_keepalive(socket, *keepalive)
387
389
  if tls
388
390
  cert_store = OpenSSL::X509::Store.new
389
391
  cert_store.set_default_paths
@@ -398,6 +400,8 @@ module AMQP
398
400
  socket.post_connection_check(host) || raise(Error, "TLS certificate hostname doesn't match requested")
399
401
  end
400
402
  socket
403
+ rescue SystemCallError, OpenSSL::OpenSSLError => e
404
+ raise Error, "Could not open a socket: #{e.message}"
401
405
  end
402
406
 
403
407
  # Negotiate a connection
@@ -462,11 +466,18 @@ module AMQP
462
466
 
463
467
  # Enable TCP keepalive, which is prefered to heartbeats
464
468
  # @return [void]
465
- def enable_tcp_keepalive(socket)
469
+ def enable_tcp_keepalive(socket, idle = 60, interval = 10, count = 3)
466
470
  socket.setsockopt(Socket::SOL_SOCKET, Socket::SO_KEEPALIVE, true)
467
- socket.setsockopt(Socket::SOL_TCP, Socket::TCP_KEEPIDLE, 60)
468
- socket.setsockopt(Socket::SOL_TCP, Socket::TCP_KEEPINTVL, 10)
469
- socket.setsockopt(Socket::SOL_TCP, Socket::TCP_KEEPCNT, 3)
471
+ if Socket.const_defined?(:TCP_KEEPIDLE) # linux/bsd
472
+ socket.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_KEEPIDLE, idle)
473
+ elsif RUBY_PLATFORM.include? "darwin" # os x
474
+ # https://www.quickhack.net/nom/blog/2018-01-19-enable-tcp-keepalive-of-macos-and-linux-in-ruby.html
475
+ socket.setsockopt(Socket::IPPROTO_TCP, 0x10, idle)
476
+ else # windows
477
+ return
478
+ end
479
+ socket.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_KEEPINTVL, interval)
480
+ socket.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_KEEPCNT, count)
470
481
  rescue StandardError => e
471
482
  warn "AMQP-Client could not enable TCP keepalive on socket. #{e.inspect}"
472
483
  end
@@ -3,6 +3,6 @@
3
3
  module AMQP
4
4
  class Client
5
5
  # Version of the client library
6
- VERSION = "1.1.2"
6
+ VERSION = "1.1.3"
7
7
  end
8
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: amqp-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carl Hörberg
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-10-15 00:00:00.000000000 Z
11
+ date: 2021-11-04 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Work in progress
14
14
  email: