ably-rest 1.1.7 → 1.1.8
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/lib/submodules/ably-ruby/CHANGELOG.md +59 -0
- data/lib/submodules/ably-ruby/COPYRIGHT +1 -1
- data/lib/submodules/ably-ruby/SPEC.md +0 -7
- data/lib/submodules/ably-ruby/ably.gemspec +1 -1
- data/lib/submodules/ably-ruby/lib/ably/models/connection_details.rb +8 -2
- data/lib/submodules/ably-ruby/lib/ably/models/delta_extras.rb +29 -0
- data/lib/submodules/ably-ruby/lib/ably/models/error_info.rb +6 -2
- data/lib/submodules/ably-ruby/lib/ably/models/message.rb +11 -0
- data/lib/submodules/ably-ruby/lib/ably/models/protocol_message.rb +5 -8
- data/lib/submodules/ably-ruby/lib/ably/realtime/channel/channel_state_machine.rb +5 -1
- data/lib/submodules/ably-ruby/lib/ably/realtime/channel/publisher.rb +3 -2
- data/lib/submodules/ably-ruby/lib/ably/realtime/channel.rb +2 -0
- data/lib/submodules/ably-ruby/lib/ably/realtime/connection/connection_manager.rb +13 -4
- data/lib/submodules/ably-ruby/lib/ably/realtime/connection/connection_state_machine.rb +4 -0
- data/lib/submodules/ably-ruby/lib/ably/realtime/connection.rb +0 -3
- data/lib/submodules/ably-ruby/lib/ably/rest/channel.rb +4 -3
- data/lib/submodules/ably-ruby/lib/ably/rest/client.rb +16 -4
- data/lib/submodules/ably-ruby/lib/ably/version.rb +1 -1
- data/lib/submodules/ably-ruby/spec/acceptance/realtime/channel_spec.rb +212 -7
- data/lib/submodules/ably-ruby/spec/acceptance/realtime/connection_failures_spec.rb +56 -1
- data/lib/submodules/ably-ruby/spec/acceptance/realtime/connection_spec.rb +249 -0
- data/lib/submodules/ably-ruby/spec/acceptance/realtime/presence_spec.rb +18 -1
- data/lib/submodules/ably-ruby/spec/acceptance/rest/channel_spec.rb +73 -11
- data/lib/submodules/ably-ruby/spec/acceptance/rest/channels_spec.rb +1 -1
- data/lib/submodules/ably-ruby/spec/support/test_app.rb +1 -1
- data/lib/submodules/ably-ruby/spec/unit/models/delta_extras_spec.rb +14 -0
- data/lib/submodules/ably-ruby/spec/unit/models/error_info_spec.rb +17 -1
- data/lib/submodules/ably-ruby/spec/unit/models/message_spec.rb +24 -0
- data/lib/submodules/ably-ruby/spec/unit/models/protocol_message_spec.rb +24 -20
- data/lib/submodules/ably-ruby/spec/unit/realtime/channel_spec.rb +2 -1
- data/lib/submodules/ably-ruby/spec/unit/realtime/channels_spec.rb +3 -3
- data/lib/submodules/ably-ruby/spec/unit/rest/channel_spec.rb +40 -7
- data/lib/submodules/ably-ruby/spec/unit/rest/client_spec.rb +27 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6cb0c9ef4ee7da9e604043ee6eed860d338fcb61b06819e1e0f254b9a774b1e8
|
4
|
+
data.tar.gz: af47c898223d1d3e910004a95a3853d3a20570985a2457b3f6d37180133fa748
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 91d79537ad7600cd1f708395d0de17cc7b3cbe8a278182cd9b9cf8e13232f4ca025723a1cca685ab1a62054131cc6c831e3f7c30db8a26de0cbae386925af0c4
|
7
|
+
data.tar.gz: 9a48f707d972116da4726637e6be5dc128459dbcb49134c6d8f3e10745b0a859bab2df61a073f8862f6e414fcad9f70371a5a63a3b74a6431e117eaf17dc66f3
|
@@ -1,5 +1,64 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## [v1.1.8](https://github.com/ably/ably-ruby/tree/v1.1.8)
|
4
|
+
|
5
|
+
[Full Changelog](https://github.com/ably/ably-ruby/compare/v1.1.7...v1.1.8)
|
6
|
+
|
7
|
+
**Fixed bugs:**
|
8
|
+
|
9
|
+
- Lib apparently closing the socket after each request [\#211](https://github.com/ably/ably-ruby/issues/211)
|
10
|
+
|
11
|
+
**Closed issues:**
|
12
|
+
|
13
|
+
- Resolve config.around\(\) issue and upgrade rspec [\#313](https://github.com/ably/ably-ruby/issues/313)
|
14
|
+
- Write spec tests for RTL21 [\#308](https://github.com/ably/ably-ruby/issues/308)
|
15
|
+
- Write spec tests for RTL20 [\#307](https://github.com/ably/ably-ruby/issues/307)
|
16
|
+
- Write spec tests for RTL19, RTL19a, b, c [\#306](https://github.com/ably/ably-ruby/issues/306)
|
17
|
+
- Write spec tests for RTL18, RTL18a, b, c [\#305](https://github.com/ably/ably-ruby/issues/305)
|
18
|
+
- Add support for RTL20 [\#295](https://github.com/ably/ably-ruby/issues/295)
|
19
|
+
- Add support for RTL19, RTL19a, b, c [\#294](https://github.com/ably/ably-ruby/issues/294)
|
20
|
+
- Add support for RTL18, RTL18a, b, c [\#293](https://github.com/ably/ably-ruby/issues/293)
|
21
|
+
- Write spec tests for RSL6b, RLS7 \(Channels\) [\#284](https://github.com/ably/ably-ruby/issues/284)
|
22
|
+
- Write spec tests for RSC15e, d, f \(Host Fallback \)
|
23
|
+
[\#280](https://github.com/ably/ably-ruby/issues/280)
|
24
|
+
- Write spec tests for RSC7a, RSC7c \(RestClient\)
|
25
|
+
[\#279](https://github.com/ably/ably-ruby/issues/279)
|
26
|
+
- Add support for DataTypes ChannelOptions TB2c, d [\#278](https://github.com/ably/ably-ruby/issues/278)
|
27
|
+
- Add support for DataTypes TokenParams AO2g [\#277](https://github.com/ably/ably-ruby/issues/277)
|
28
|
+
- Add support for DataTypes ClientOptions TO3j10 [\#276](https://github.com/ably/ably-ruby/issues/276)
|
29
|
+
- Add support for DataTypes ErrorInfo TI1 [\#275](https://github.com/ably/ably-ruby/issues/275)
|
30
|
+
- Add support for DataTypes ProtocolMessage TR3f, TR4i, q [\#274](https://github.com/ably/ably-ruby/issues/274)
|
31
|
+
- Add support for TM2i \(DataTypes Message\) [\#273](https://github.com/ably/ably-ruby/issues/273)
|
32
|
+
- Add support for PC1, PC2, PC3, PC3a \(Plugins\) [\#272](https://github.com/ably/ably-ruby/issues/272)
|
33
|
+
- Add support for RSL6b, RLS7 \(Channels\) [\#271](https://github.com/ably/ably-ruby/issues/271)
|
34
|
+
- Add support for RSL1a, b, h, k1, k2, l, l1 \(Channels\) [\#270](https://github.com/ably/ably-ruby/issues/270)
|
35
|
+
- Add support for RSC15e, d, f \(Host Fallback \)
|
36
|
+
[\#267](https://github.com/ably/ably-ruby/issues/267)
|
37
|
+
- Update client options support to 1.1 spec level \(logExceptionReportingUrl\) [\#246](https://github.com/ably/ably-ruby/issues/246)
|
38
|
+
- Confirm status of remaining realtime spec items for 1.0 [\#244](https://github.com/ably/ably-ruby/issues/244)
|
39
|
+
|
40
|
+
**Merged pull requests:**
|
41
|
+
|
42
|
+
- Allowing ConnectionDetails\#max\_message\_size [\#342](https://github.com/ably/ably-ruby/pull/342) ([lukaszsliwa](https://github.com/lukaszsliwa))
|
43
|
+
- Add specs for RTL17 [\#335](https://github.com/ably/ably-ruby/pull/335) ([TheSmartnik](https://github.com/TheSmartnik))
|
44
|
+
- Add spec for RTP5b [\#332](https://github.com/ably/ably-ruby/pull/332) ([TheSmartnik](https://github.com/TheSmartnik))
|
45
|
+
- Update specs with comments to docs seciton for RSN3a/RSN3c [\#331](https://github.com/ably/ably-ruby/pull/331) ([TheSmartnik](https://github.com/TheSmartnik))
|
46
|
+
- Fix after suite hook in specs [\#329](https://github.com/ably/ably-ruby/pull/329) ([TheSmartnik](https://github.com/TheSmartnik))
|
47
|
+
- Add specs for RTN15h2 [\#328](https://github.com/ably/ably-ruby/pull/328) ([TheSmartnik](https://github.com/TheSmartnik))
|
48
|
+
- Add specs for RTN12f [\#327](https://github.com/ably/ably-ruby/pull/327) ([TheSmartnik](https://github.com/TheSmartnik))
|
49
|
+
- Added Channel\#set\_options and Channel\#options= aliases [\#326](https://github.com/ably/ably-ruby/pull/326) ([lukaszsliwa](https://github.com/lukaszsliwa))
|
50
|
+
- Added DeltaExtras class and Message\#delta\_extras method. \(TM2i\) [\#325](https://github.com/ably/ably-ruby/pull/325) ([lukaszsliwa](https://github.com/lukaszsliwa))
|
51
|
+
- When connection disconnectes and can't renew token it fails \(RTN15h1\) [\#324](https://github.com/ably/ably-ruby/pull/324) ([TheSmartnik](https://github.com/TheSmartnik))
|
52
|
+
- RTN-13c Add spec that channels do not reattach when connection isn't connected [\#323](https://github.com/ably/ably-ruby/pull/323) ([TheSmartnik](https://github.com/TheSmartnik))
|
53
|
+
- Add support for DataTypes ProtocolMessage: has\_attach\_resume\_flag? [\#322](https://github.com/ably/ably-ruby/pull/322) ([lukaszsliwa](https://github.com/lukaszsliwa))
|
54
|
+
- Added request\_id and cause attributes to the ErrorInfo class TI1, RSC7c [\#321](https://github.com/ably/ably-ruby/pull/321) ([lukaszsliwa](https://github.com/lukaszsliwa))
|
55
|
+
- Add spec for RTN12d [\#318](https://github.com/ably/ably-ruby/pull/318) ([TheSmartnik](https://github.com/TheSmartnik))
|
56
|
+
- Change behavior when reconnecting from failed state \(RTN11d\) [\#316](https://github.com/ably/ably-ruby/pull/316) ([TheSmartnik](https://github.com/TheSmartnik))
|
57
|
+
- Remove deprecated ProtocolMessage\#connection\_key TR4e [\#315](https://github.com/ably/ably-ruby/pull/315) ([TheSmartnik](https://github.com/TheSmartnik))
|
58
|
+
- Upgrade rspec to 3.10 [\#314](https://github.com/ably/ably-ruby/pull/314) ([lukaszsliwa](https://github.com/lukaszsliwa))
|
59
|
+
- Add a spec for \#RTN11c [\#257](https://github.com/ably/ably-ruby/pull/257) ([TheSmartnik](https://github.com/TheSmartnik))
|
60
|
+
|
61
|
+
|
3
62
|
## [v1.1.7](https://github.com/ably/ably-ruby/tree/v1.1.7)
|
4
63
|
|
5
64
|
[Full Changelog](https://github.com/ably/ably-ruby/compare/v1.1.6...v1.1.7)
|
@@ -1 +1 @@
|
|
1
|
-
Copyright 2015-
|
1
|
+
Copyright 2015-2022 Ably Real-time Ltd (ably.com)
|
@@ -3299,8 +3299,6 @@ _(see [spec/unit/models/protocol_message_spec.rb](./spec/unit/models/protocol_me
|
|
3299
3299
|
* [retrieves attribute :channel_serial](./spec/shared/model_behaviour.rb#L15)
|
3300
3300
|
* #connection_id
|
3301
3301
|
* [retrieves attribute :connection_id](./spec/shared/model_behaviour.rb#L15)
|
3302
|
-
* #connection_key
|
3303
|
-
* [retrieves attribute :connection_key](./spec/shared/model_behaviour.rb#L15)
|
3304
3302
|
* #==
|
3305
3303
|
* [is true when attributes are the same](./spec/shared/model_behaviour.rb#L41)
|
3306
3304
|
* [is false when attributes are not the same](./spec/shared/model_behaviour.rb#L46)
|
@@ -3386,11 +3384,6 @@ _(see [spec/unit/models/protocol_message_spec.rb](./spec/unit/models/protocol_me
|
|
3386
3384
|
* [contains the attributes from the JSON auth details](./spec/unit/models/protocol_message_spec.rb#L358)
|
3387
3385
|
* without a JSON value
|
3388
3386
|
* [contains an empty AuthDetails object](./spec/unit/models/protocol_message_spec.rb#L366)
|
3389
|
-
* #connection_key (#TR4e)
|
3390
|
-
* existing only in #connection_details.connection_key
|
3391
|
-
* [is returned](./spec/unit/models/protocol_message_spec.rb#L377)
|
3392
|
-
* existing in both #connection_key and #connection_details.connection_key
|
3393
|
-
* [returns #connection_details.connection_key as #connection_key will be deprecated > 0.8](./spec/unit/models/protocol_message_spec.rb#L385)
|
3394
3387
|
|
3395
3388
|
### Ably::Models::PushChannelSubscription
|
3396
3389
|
_(see [spec/unit/models/push_channel_subscription_spec.rb](./spec/unit/models/push_channel_subscription_spec.rb))_
|
@@ -35,7 +35,7 @@ Gem::Specification.new do |spec|
|
|
35
35
|
|
36
36
|
spec.add_development_dependency 'rake', '~> 13.0'
|
37
37
|
spec.add_development_dependency 'redcarpet', '~> 3.3'
|
38
|
-
spec.add_development_dependency 'rspec', '~> 3.
|
38
|
+
spec.add_development_dependency 'rspec', '~> 3.10.0'
|
39
39
|
spec.add_development_dependency 'rspec-retry', '~> 0.6'
|
40
40
|
spec.add_development_dependency 'yard', '~> 0.9'
|
41
41
|
spec.add_development_dependency 'rspec-instafail', '~> 1.0'
|
@@ -21,6 +21,12 @@ module Ably::Models
|
|
21
21
|
class ConnectionDetails
|
22
22
|
include Ably::Modules::ModelCommon
|
23
23
|
|
24
|
+
# Max message size
|
25
|
+
MAX_MESSAGE_SIZE = 65536 # See spec TO3l8
|
26
|
+
|
27
|
+
# Max frame size
|
28
|
+
MAX_FRAME_SIZE = 524288 # See spec TO3l9
|
29
|
+
|
24
30
|
# @param attributes [Hash]
|
25
31
|
# @option attributes [String] :client_id contains the client ID assigned to the connection
|
26
32
|
# @option attributes [String] :connection_key the connection secret key string that is used to resume a connection and its state
|
@@ -38,8 +44,8 @@ module Ably::Models
|
|
38
44
|
self.attributes[duration_field] = (self.attributes[duration_field].to_f / 1000).round
|
39
45
|
end
|
40
46
|
end
|
41
|
-
self.attributes[:max_message_size] ||=
|
42
|
-
self.attributes[:max_frame_size] ||=
|
47
|
+
self.attributes[:max_message_size] ||= MAX_MESSAGE_SIZE
|
48
|
+
self.attributes[:max_frame_size] ||= MAX_FRAME_SIZE
|
43
49
|
self.attributes.freeze
|
44
50
|
end
|
45
51
|
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Ably::Models
|
2
|
+
#
|
3
|
+
# @!attribute [r] from
|
4
|
+
# @return [String] The id of the message the delta was generated from
|
5
|
+
# @!attribute [r] format
|
6
|
+
# @return [String] The delta format. Only vcdiff is supported as at API version 1.2
|
7
|
+
#
|
8
|
+
class DeltaExtras
|
9
|
+
include Ably::Modules::ModelCommon
|
10
|
+
|
11
|
+
# The id of the message the delta was generated from.
|
12
|
+
# @return [String, nil]
|
13
|
+
#
|
14
|
+
attr_reader :from
|
15
|
+
|
16
|
+
# The delta format.
|
17
|
+
# @return [String, nil]
|
18
|
+
#
|
19
|
+
attr_reader :format
|
20
|
+
|
21
|
+
def initialize(attributes = {})
|
22
|
+
@from, @format = IdiomaticRubyWrapper((attributes || {}), stop_at: [:from, :format]).attributes.values_at(:from, :format)
|
23
|
+
end
|
24
|
+
|
25
|
+
def to_json(*args)
|
26
|
+
as_json(args).to_json
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -27,6 +27,10 @@ module Ably::Models
|
|
27
27
|
# @return [Integer] Ably error code (see ably-common/protocol/errors.json)
|
28
28
|
# @!attribute [r] status
|
29
29
|
# @return [Integer] HTTP Status Code corresponding to this error, where applicable
|
30
|
+
# @!attribute [r] request_id
|
31
|
+
# @return [Integer] HTTP RequestId corresponding to this error, where applicable (#RSC7c)
|
32
|
+
# @!attribute [r] cause
|
33
|
+
# @return [Integer] HTTP Status Code corresponding to this error, where applicable (#TI1)
|
30
34
|
# @!attribute [r] attributes
|
31
35
|
# @return [Hash] Access the protocol message Hash object ruby'fied to use symbolized keys
|
32
36
|
#
|
@@ -38,7 +42,7 @@ module Ably::Models
|
|
38
42
|
@hash_object = IdiomaticRubyWrapper(hash_object.clone.freeze)
|
39
43
|
end
|
40
44
|
|
41
|
-
%w(message code href status_code).each do |attribute|
|
45
|
+
%w(message code href status_code request_id cause).each do |attribute|
|
42
46
|
define_method attribute do
|
43
47
|
attributes[attribute.to_sym]
|
44
48
|
end
|
@@ -52,7 +56,7 @@ module Ably::Models
|
|
52
56
|
def to_s
|
53
57
|
error_href = href || (code ? "https://help.ably.io/error/#{code}" : '')
|
54
58
|
see_msg = " -> see #{error_href} for help" unless message.to_s.include?(error_href.to_s)
|
55
|
-
"<Error: #{message} (code: #{code}, http status: #{status})>#{see_msg}"
|
59
|
+
"<Error: #{message} (code: #{code}, http status: #{status} request_id: #{request_id} cause: #{cause})>#{see_msg}"
|
56
60
|
end
|
57
61
|
end
|
58
62
|
end
|
@@ -142,6 +142,9 @@ module Ably::Models
|
|
142
142
|
|
143
143
|
# Contains any arbitrary key value pairs which may also contain other primitive JSON types, JSON-encodable objects or JSON-encodable arrays.
|
144
144
|
# The extras field is provided to contain message metadata and/or ancillary payloads in support of specific functionality, e.g. push
|
145
|
+
# 1.2 adds the delta extension which is of type DeltaExtras, and the headers extension, which contains arbitrary string->string key-value pairs,
|
146
|
+
# settable at publish time. Unless otherwise specified, the client library should not attempt to do any filtering or validation of the extras
|
147
|
+
# field itself, but should treat it opaquely, encoding it and passing it to realtime unaltered.
|
145
148
|
# @api private
|
146
149
|
def extras
|
147
150
|
attributes[:extras].tap do |val|
|
@@ -151,6 +154,14 @@ module Ably::Models
|
|
151
154
|
end
|
152
155
|
end
|
153
156
|
|
157
|
+
# Delta extras extension (TM2i)
|
158
|
+
# @return [DeltaExtras, nil]
|
159
|
+
# @api private
|
160
|
+
def delta_extras
|
161
|
+
return nil if attributes[:extras][:delta].nil?
|
162
|
+
@delta_extras ||= DeltaExtras.new(attributes[:extras][:delta]).freeze
|
163
|
+
end
|
164
|
+
|
154
165
|
private
|
155
166
|
def raw_hash_object
|
156
167
|
@raw_hash_object
|
@@ -19,8 +19,6 @@ module Ably::Models
|
|
19
19
|
# @!attribute [r] channel_serial
|
20
20
|
# @return [String] Contains a serial number for a message on the current channel
|
21
21
|
# @!attribute [r] connection_id
|
22
|
-
# @return [String] Contains a string public identifier for the connection
|
23
|
-
# @!attribute [r] connection_key
|
24
22
|
# @return [String] Contains a string private connection key used to recover this connection
|
25
23
|
# @!attribute [r] connection_serial
|
26
24
|
# @return [Bignum] Contains a serial number for a message sent from the server to the client
|
@@ -98,12 +96,6 @@ module Ably::Models
|
|
98
96
|
end
|
99
97
|
end
|
100
98
|
|
101
|
-
def connection_key
|
102
|
-
# connection_key in connection details takes precedence over connection_key on the ProtocolMessage
|
103
|
-
# connection_key in the ProtocolMessage will be deprecated in future protocol versions > 0.8
|
104
|
-
connection_details.connection_key || attributes[:connection_key]
|
105
|
-
end
|
106
|
-
|
107
99
|
def id!
|
108
100
|
raise RuntimeError, 'ProtocolMessage #id is nil' unless id
|
109
101
|
id
|
@@ -224,6 +216,11 @@ module Ably::Models
|
|
224
216
|
flags & 16 == 16 # 2^4
|
225
217
|
end
|
226
218
|
|
219
|
+
# @api private
|
220
|
+
def has_attach_resume_flag?
|
221
|
+
flags & 32 == 32 # 2^5
|
222
|
+
end
|
223
|
+
|
227
224
|
# @api private
|
228
225
|
def has_attach_presence_flag?
|
229
226
|
flags & 65536 == 65536 # 2^16
|
@@ -26,12 +26,16 @@ module Ably::Realtime
|
|
26
26
|
transition :from => :detaching, :to => [:detached, :attaching, :attached, :failed, :suspended]
|
27
27
|
transition :from => :detached, :to => [:attaching, :attached, :failed]
|
28
28
|
transition :from => :suspended, :to => [:attaching, :attached, :detached, :failed]
|
29
|
-
transition :from => :failed, :to => [:attaching]
|
29
|
+
transition :from => :failed, :to => [:attaching, :initialized]
|
30
30
|
|
31
31
|
after_transition do |channel, transition|
|
32
32
|
channel.synchronize_state_with_statemachine
|
33
33
|
end
|
34
34
|
|
35
|
+
after_transition(to: [:initialized]) do |channel|
|
36
|
+
channel.clear_error_reason
|
37
|
+
end
|
38
|
+
|
35
39
|
after_transition(to: [:attaching]) do |channel|
|
36
40
|
channel.manager.attach
|
37
41
|
end
|
@@ -22,8 +22,9 @@ module Ably::Realtime
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
-
|
26
|
-
|
25
|
+
max_message_size = connection.details && connection.details.max_message_size || Ably::Models::ConnectionDetails::MAX_MESSAGE_SIZE
|
26
|
+
if messages.sum(&:size) > max_message_size
|
27
|
+
error = Ably::Exceptions::MaxMessageSizeExceeded.new("Message size exceeded #{max_message_size} bytes.")
|
27
28
|
return Ably::Util::SafeDeferrable.new_and_fail_immediately(logger, error)
|
28
29
|
end
|
29
30
|
|
@@ -323,6 +323,8 @@ module Ably
|
|
323
323
|
def update_options(channel_options)
|
324
324
|
@options = channel_options.clone.freeze
|
325
325
|
end
|
326
|
+
alias set_options update_options # (RSL7)
|
327
|
+
alias options= update_options
|
326
328
|
|
327
329
|
# Used by {Ably::Modules::StateEmitter} to debug state changes
|
328
330
|
# @api private
|
@@ -117,17 +117,17 @@ module Ably::Realtime
|
|
117
117
|
EventMachine.next_tick { connection.trigger_resumed }
|
118
118
|
resend_pending_message_ack_queue
|
119
119
|
else
|
120
|
-
logger.debug { "ConnectionManager: Connection was not resumed, old connection ID #{connection.id} has been updated with new connection ID #{protocol_message.connection_id} and key #{protocol_message.connection_key}" }
|
120
|
+
logger.debug { "ConnectionManager: Connection was not resumed, old connection ID #{connection.id} has been updated with new connection ID #{protocol_message.connection_id} and key #{protocol_message.connection_details.connection_key}" }
|
121
121
|
nack_messages_on_all_channels protocol_message.error
|
122
122
|
force_reattach_on_channels protocol_message.error
|
123
123
|
end
|
124
124
|
else
|
125
|
-
logger.debug { "ConnectionManager: New connection created with ID #{protocol_message.connection_id} and key #{protocol_message.connection_key}" }
|
125
|
+
logger.debug { "ConnectionManager: New connection created with ID #{protocol_message.connection_id} and key #{protocol_message.connection_details.connection_key}" }
|
126
126
|
end
|
127
127
|
|
128
128
|
reattach_suspended_channels protocol_message.error
|
129
129
|
|
130
|
-
connection.configure_new protocol_message.connection_id, protocol_message.connection_key, protocol_message.connection_serial
|
130
|
+
connection.configure_new protocol_message.connection_id, protocol_message.connection_details.connection_key, protocol_message.connection_serial
|
131
131
|
end
|
132
132
|
|
133
133
|
# When connection is CONNECTED and receives an update
|
@@ -139,7 +139,7 @@ module Ably::Realtime
|
|
139
139
|
# Update the connection details and any associated defaults
|
140
140
|
connection.set_connection_details protocol_message.connection_details
|
141
141
|
|
142
|
-
connection.configure_new protocol_message.connection_id, protocol_message.connection_key, protocol_message.connection_serial
|
142
|
+
connection.configure_new protocol_message.connection_id, protocol_message.connection_details.connection_key, protocol_message.connection_serial
|
143
143
|
|
144
144
|
state_change = Ably::Models::ConnectionStateChange.new(
|
145
145
|
current: connection.state,
|
@@ -319,6 +319,15 @@ module Ably::Realtime
|
|
319
319
|
end
|
320
320
|
end
|
321
321
|
|
322
|
+
# @api private
|
323
|
+
def reintialize_failed_chanels
|
324
|
+
channels.select do |channel|
|
325
|
+
channel.failed?
|
326
|
+
end.each do |channel|
|
327
|
+
channel.transition_state_machine :initialized
|
328
|
+
end
|
329
|
+
end
|
330
|
+
|
322
331
|
# When continuity on a connection is lost all messages
|
323
332
|
# whether queued or awaiting an ACK must be NACK'd as we now have a new connection
|
324
333
|
def nack_messages_on_all_channels(error)
|
@@ -36,6 +36,10 @@ module Ably::Realtime
|
|
36
36
|
connection.manager.setup_transport
|
37
37
|
end
|
38
38
|
|
39
|
+
after_transition(to: [:connecting], from: [:failed]) do |connection|
|
40
|
+
connection.manager.reintialize_failed_chanels
|
41
|
+
end
|
42
|
+
|
39
43
|
after_transition(to: [:connecting], from: [:disconnected, :suspended]) do |connection|
|
40
44
|
connection.manager.reconnect_transport
|
41
45
|
end
|
@@ -82,9 +82,6 @@ module Ably
|
|
82
82
|
# Max number of messages to bundle in a single ProtocolMessage
|
83
83
|
MAX_PROTOCOL_MESSAGE_BATCH_SIZE = 50
|
84
84
|
|
85
|
-
# Max message size
|
86
|
-
MAX_MESSAGE_SIZE = 65536 # See spec TO3l8
|
87
|
-
|
88
85
|
# A unique public identifier for this connection, used to identify this member in presence events and messages
|
89
86
|
# @return [String]
|
90
87
|
attr_reader :id
|
@@ -23,7 +23,6 @@ module Ably
|
|
23
23
|
attr_reader :push
|
24
24
|
|
25
25
|
IDEMPOTENT_LIBRARY_GENERATED_ID_LENGTH = 9 # See spec RSL1k1
|
26
|
-
MAX_MESSAGE_SIZE = 65536 # See spec TO3l8
|
27
26
|
|
28
27
|
# Initialize a new Channel object
|
29
28
|
#
|
@@ -88,8 +87,8 @@ module Ably
|
|
88
87
|
|
89
88
|
messages.map! { |message| Ably::Models::Message(message.dup) }
|
90
89
|
|
91
|
-
if messages.sum(&:size) > Ably::Rest::
|
92
|
-
raise Ably::Exceptions::MaxMessageSizeExceeded.new("Maximum message size exceeded #{
|
90
|
+
if messages.sum(&:size) > (max_message_size = client.max_message_size || Ably::Rest::Client::MAX_MESSAGE_SIZE)
|
91
|
+
raise Ably::Exceptions::MaxMessageSizeExceeded.new("Maximum message size exceeded #{max_message_size} bytes.")
|
93
92
|
end
|
94
93
|
|
95
94
|
payload = messages.map do |message|
|
@@ -168,6 +167,8 @@ module Ably
|
|
168
167
|
def update_options(channel_options)
|
169
168
|
@options = channel_options.clone.freeze
|
170
169
|
end
|
170
|
+
alias set_options update_options # (RSL7)
|
171
|
+
alias options= update_options
|
171
172
|
|
172
173
|
private
|
173
174
|
def base_path
|
@@ -25,7 +25,8 @@ module Ably
|
|
25
25
|
# Default Ably domain for REST
|
26
26
|
DOMAIN = 'rest.ably.io'
|
27
27
|
|
28
|
-
|
28
|
+
MAX_MESSAGE_SIZE = 65536 # See spec TO3l8
|
29
|
+
MAX_FRAME_SIZE = 524288 # See spec TO3l8
|
29
30
|
|
30
31
|
# Configuration for HTTP timeouts and HTTP request reattempts to fallback hosts
|
31
32
|
HTTP_DEFAULTS = {
|
@@ -118,6 +119,14 @@ module Ably
|
|
118
119
|
# @return [Boolean]
|
119
120
|
attr_reader :idempotent_rest_publishing
|
120
121
|
|
122
|
+
# Max message size (TO2, TO3l8) by default (65536 bytes) 64KiB
|
123
|
+
# @return [Integer]
|
124
|
+
attr_reader :max_message_size
|
125
|
+
|
126
|
+
# Max frame size (TO2, TO3l8) by default (524288 bytes) 512KiB
|
127
|
+
# @return [Integer]
|
128
|
+
attr_reader :max_frame_size
|
129
|
+
|
121
130
|
# Creates a {Ably::Rest::Client Rest Client} and configures the {Ably::Auth} object for the connection.
|
122
131
|
#
|
123
132
|
# @param [Hash,String] options an options Hash used to configure the client and the authentication, or String with an API key or Token ID
|
@@ -152,6 +161,8 @@ module Ably
|
|
152
161
|
#
|
153
162
|
# @option options [Boolean] :add_request_ids (false) When true, adds a unique request_id to each request sent to Ably servers. This is handy when reporting issues, because you can refer to a specific request.
|
154
163
|
# @option options [Boolean] :idempotent_rest_publishing (false if ver < 1.2) When true, idempotent publishing is enabled for all messages published via REST
|
164
|
+
# @option options [Integer] :max_message_size (65536 bytes) Maximum size of all messages when publishing via REST publish()
|
165
|
+
# @option options [Integer] :max_frame_size (524288 bytes) Maximum size of frame
|
155
166
|
#
|
156
167
|
# @return [Ably::Rest::Client]
|
157
168
|
#
|
@@ -189,7 +200,8 @@ module Ably
|
|
189
200
|
@add_request_ids = options.delete(:add_request_ids)
|
190
201
|
@log_retries_as_info = options.delete(:log_retries_as_info)
|
191
202
|
@idempotent_rest_publishing = options.delete(:idempotent_rest_publishing) || Ably.major_minor_version_numeric > 1.1
|
192
|
-
|
203
|
+
@max_message_size = options.delete(:max_message_size) || MAX_MESSAGE_SIZE
|
204
|
+
@max_frame_size = options.delete(:max_frame_size) || MAX_FRAME_SIZE
|
193
205
|
|
194
206
|
if options[:fallback_hosts_use_default] && options[:fallback_hosts]
|
195
207
|
raise ArgumentError, "fallback_hosts_use_default cannot be set to try when fallback_hosts is also provided"
|
@@ -365,8 +377,8 @@ module Ably
|
|
365
377
|
send_request(method, path, params, headers: headers)
|
366
378
|
end
|
367
379
|
when :post, :patch, :put
|
368
|
-
if body.to_json.bytesize >
|
369
|
-
raise Ably::Exceptions::MaxFrameSizeExceeded.new("Maximum frame size exceeded #{
|
380
|
+
if body.to_json.bytesize > max_frame_size
|
381
|
+
raise Ably::Exceptions::MaxFrameSizeExceeded.new("Maximum frame size exceeded #{max_frame_size} bytes.")
|
370
382
|
end
|
371
383
|
path_with_params = Addressable::URI.new
|
372
384
|
path_with_params.query_values = params || {}
|