ably 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/CHANGELOG.md +19 -4
- data/lib/ably/realtime/connection.rb +16 -3
- data/lib/ably/version.rb +1 -1
- data/spec/acceptance/realtime/connection_failures_spec.rb +44 -0
- data/spec/acceptance/realtime/connection_spec.rb +2 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f84e069f72578aa8f1dd02fb6925da8a03cb702a
|
4
|
+
data.tar.gz: 0d96682769ebf4ed7b9d0d9fc84603e2a99101fe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 139bc0db9fc45e8814c352d8e046666eebb3123c46898256ca3f6c47cf9d66ad86d2dbf76a63ffbf3fdaad0b0f23c3b46c4062e4b5811892481295748826510b
|
7
|
+
data.tar.gz: e4f947a9eb775db94fb413522b935120b5f3ee9d4b6df965ba1c82c676034d5fe653e1120a52c45ae45713c522bed5d582b79cc24e541f69e857cab0c8874284
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,11 +1,26 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
-
## [v1.0.
|
4
|
-
|
3
|
+
## [v1.0.2](https://github.com/ably/ably-ruby/tree/v1.0.2)
|
4
|
+
|
5
|
+
[Full Changelog](https://github.com/ably/ably-ruby/compare/v1.0.1...v1.0.2)
|
6
|
+
|
7
|
+
**Fixed bugs:**
|
8
|
+
|
9
|
+
- Reconnect following disconnection is hitting a 403 error [\#117](https://github.com/ably/ably-ruby/issues/117)
|
10
|
+
- [Fallback hosts were used upon any disconnection as opposed to only when the primary host is unavailable](https://github.com/ably/ably-ruby/pull/120)
|
5
11
|
|
6
|
-
|
12
|
+
**Merged pull requests:**
|
13
|
+
|
14
|
+
- Fallback fixes [\#120](https://github.com/ably/ably-ruby/pull/120) ([mattheworiordan](https://github.com/mattheworiordan))
|
15
|
+
|
16
|
+
## [v1.0.1](https://github.com/ably/ably-ruby/tree/v1.0.1) (2017-05-11)
|
17
|
+
[Full Changelog](https://github.com/ably/ably-ruby/compare/v1.0.0...v1.0.1)
|
18
|
+
|
19
|
+
## [v1.0.0](https://github.com/ably/ably-ruby/tree/v1.0.0) (2017-03-07)
|
20
|
+
[Full Changelog](https://github.com/ably/ably-ruby/compare/v0.8.15...v1.0.0)
|
7
21
|
|
8
|
-
|
22
|
+
## [v0.8.15](https://github.com/ably/ably-ruby/tree/v0.8.15) (2017-03-07)
|
23
|
+
[Full Changelog](https://github.com/ably/ably-ruby/compare/v0.8.14...v0.8.15)
|
9
24
|
|
10
25
|
**Implemented enhancements:**
|
11
26
|
|
@@ -351,7 +351,7 @@ module Ably
|
|
351
351
|
def determine_host
|
352
352
|
raise ArgumentError, 'Block required' unless block_given?
|
353
353
|
|
354
|
-
if
|
354
|
+
if should_use_fallback_hosts?
|
355
355
|
internet_up? do |internet_is_up_result|
|
356
356
|
@current_host = if internet_is_up_result
|
357
357
|
client.fallback_endpoint.host
|
@@ -445,6 +445,10 @@ module Ably
|
|
445
445
|
end
|
446
446
|
|
447
447
|
determine_host do |host|
|
448
|
+
# Ensure the hostname matches the fallback host name
|
449
|
+
url.hostname = host
|
450
|
+
url.port = port
|
451
|
+
|
448
452
|
begin
|
449
453
|
logger.debug { "Connection: Opening socket connection to #{host}:#{port}/#{url.path}?#{url.query}" }
|
450
454
|
@transport = create_transport(host, port, url) do |websocket_transport|
|
@@ -510,6 +514,7 @@ module Ably
|
|
510
514
|
|
511
515
|
# @api private
|
512
516
|
def create_transport(host, port, url, &block)
|
517
|
+
logger.debug { "Connection: EventMachine connecting to #{host}:#{port} with URL: #{url}" }
|
513
518
|
EventMachine.connect(host, port, WebsocketTransport, self, url.to_s, &block)
|
514
519
|
end
|
515
520
|
|
@@ -642,14 +647,22 @@ module Ably
|
|
642
647
|
!!client.custom_realtime_host
|
643
648
|
end
|
644
649
|
|
645
|
-
def
|
650
|
+
def should_use_fallback_hosts?
|
646
651
|
if client.fallback_hosts && !client.fallback_hosts.empty?
|
647
|
-
if connecting? && previous_state
|
652
|
+
if connecting? && previous_state && !disconnected_from_connected_state?
|
648
653
|
use_fallback_if_disconnected? || use_fallback_if_suspended?
|
649
654
|
end
|
650
655
|
end
|
651
656
|
end
|
652
657
|
|
658
|
+
def disconnected_from_connected_state?
|
659
|
+
most_recent_state_changes = state_history.last(3).first(2) # Ignore current state
|
660
|
+
|
661
|
+
# A valid connection was disconnected
|
662
|
+
most_recent_state_changes.last.fetch(:state) == Connection::STATE.Disconnected &&
|
663
|
+
most_recent_state_changes.first.fetch(:state) == Connection::STATE.Connected
|
664
|
+
end
|
665
|
+
|
653
666
|
def use_fallback_if_disconnected?
|
654
667
|
second_reconnect_attempt_for(:disconnected, 1)
|
655
668
|
end
|
data/lib/ably/version.rb
CHANGED
@@ -1178,6 +1178,27 @@ describe Ably::Realtime::Connection, 'failures', :event_machine do
|
|
1178
1178
|
stop_reactor
|
1179
1179
|
end
|
1180
1180
|
end
|
1181
|
+
|
1182
|
+
it 'does not use a fallback host if the connection connects on the default host and then later becomes disconnected', em_timeout: 25 do
|
1183
|
+
request = 0
|
1184
|
+
|
1185
|
+
allow(connection).to receive(:create_transport).and_wrap_original do |wrapped_proc, host, *args, &block|
|
1186
|
+
expect(host).to eql(expected_host)
|
1187
|
+
request += 1
|
1188
|
+
wrapped_proc.call(host, *args, &block)
|
1189
|
+
end
|
1190
|
+
|
1191
|
+
connection.on(:connected) do
|
1192
|
+
if request <= 2
|
1193
|
+
EventMachine.add_timer(3) do
|
1194
|
+
# Force a disconnect
|
1195
|
+
connection.transport.unbind
|
1196
|
+
end
|
1197
|
+
else
|
1198
|
+
stop_reactor
|
1199
|
+
end
|
1200
|
+
end
|
1201
|
+
end
|
1181
1202
|
end
|
1182
1203
|
|
1183
1204
|
context ':fallback_hosts array is provided' do
|
@@ -1286,6 +1307,29 @@ describe Ably::Realtime::Connection, 'failures', :event_machine do
|
|
1286
1307
|
end
|
1287
1308
|
end
|
1288
1309
|
end
|
1310
|
+
|
1311
|
+
it 'uses the correct host name for the WebSocket requests to the fallback hosts' do
|
1312
|
+
request = 0
|
1313
|
+
expect(connection).to receive(:create_transport).at_least(:once) do |host, port, uri|
|
1314
|
+
if request == 0 || request == expected_retry_attempts + 1
|
1315
|
+
expect(uri.hostname).to eql(expected_host)
|
1316
|
+
else
|
1317
|
+
expect(custom_hosts + [expected_host]).to include(uri.hostname)
|
1318
|
+
fallback_hosts_used << host if @suspended > 0
|
1319
|
+
end
|
1320
|
+
request += 1
|
1321
|
+
raise EventMachine::ConnectionError
|
1322
|
+
end
|
1323
|
+
|
1324
|
+
connection.on(:suspended) do
|
1325
|
+
@suspended += 1
|
1326
|
+
|
1327
|
+
if @suspended > 4
|
1328
|
+
expect(fallback_hosts_used.uniq).to match_array(custom_hosts + [expected_host])
|
1329
|
+
stop_reactor
|
1330
|
+
end
|
1331
|
+
end
|
1332
|
+
end
|
1289
1333
|
end
|
1290
1334
|
|
1291
1335
|
context ':fallback_hosts array is provided by an empty array' do
|
@@ -980,6 +980,7 @@ describe Ably::Realtime::Connection, :event_machine do
|
|
980
980
|
|
981
981
|
context 'transport-level heartbeats are supported in the websocket transport' do
|
982
982
|
it 'provides the heartbeats argument in the websocket connection params (#RTN23b)' do
|
983
|
+
skip 'Native heartbeats not yet supported in the WS driver https://github.com/ably/ably-ruby/issues/116'
|
983
984
|
expect(EventMachine).to receive(:connect) do |host, port, transport, object, url|
|
984
985
|
uri = URI.parse(url)
|
985
986
|
expect(CGI::parse(uri.query)['heartbeats'][0]).to eql('false')
|
@@ -1007,6 +1008,7 @@ describe Ably::Realtime::Connection, :event_machine do
|
|
1007
1008
|
let(:client_options) { default_options.merge(websocket_heartbeats_disabled: true) }
|
1008
1009
|
|
1009
1010
|
it 'does not provide the heartbeats argument in the websocket connection params (#RTN23b)' do
|
1011
|
+
skip 'Native heartbeats not yet supported in the WS driver https://github.com/ably/ably-ruby/issues/116'
|
1010
1012
|
expect(EventMachine).to receive(:connect) do |host, port, transport, object, url|
|
1011
1013
|
uri = URI.parse(url)
|
1012
1014
|
expect(CGI::parse(uri.query)['heartbeats'][0]).to be_nil
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ably
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lewis Marshall
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-05-
|
12
|
+
date: 2017-05-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: eventmachine
|
@@ -458,7 +458,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
458
458
|
version: '0'
|
459
459
|
requirements: []
|
460
460
|
rubyforge_project:
|
461
|
-
rubygems_version: 2.
|
461
|
+
rubygems_version: 2.6.8
|
462
462
|
signing_key:
|
463
463
|
specification_version: 4
|
464
464
|
summary: A Ruby client library for ably.io realtime messaging implemented using EventMachine
|