ably 1.1.7 → 1.1.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +59 -0
  3. data/COPYRIGHT +1 -1
  4. data/SPEC.md +0 -7
  5. data/ably.gemspec +1 -1
  6. data/lib/ably/models/connection_details.rb +8 -2
  7. data/lib/ably/models/delta_extras.rb +29 -0
  8. data/lib/ably/models/error_info.rb +6 -2
  9. data/lib/ably/models/message.rb +11 -0
  10. data/lib/ably/models/protocol_message.rb +5 -8
  11. data/lib/ably/realtime/channel/channel_state_machine.rb +5 -1
  12. data/lib/ably/realtime/channel/publisher.rb +3 -2
  13. data/lib/ably/realtime/channel.rb +2 -0
  14. data/lib/ably/realtime/connection/connection_manager.rb +13 -4
  15. data/lib/ably/realtime/connection/connection_state_machine.rb +4 -0
  16. data/lib/ably/realtime/connection.rb +0 -3
  17. data/lib/ably/rest/channel.rb +4 -3
  18. data/lib/ably/rest/client.rb +16 -4
  19. data/lib/ably/version.rb +1 -1
  20. data/spec/acceptance/realtime/channel_spec.rb +212 -7
  21. data/spec/acceptance/realtime/connection_failures_spec.rb +56 -1
  22. data/spec/acceptance/realtime/connection_spec.rb +249 -0
  23. data/spec/acceptance/realtime/presence_spec.rb +18 -1
  24. data/spec/acceptance/rest/channel_spec.rb +73 -11
  25. data/spec/acceptance/rest/channels_spec.rb +1 -1
  26. data/spec/support/test_app.rb +1 -1
  27. data/spec/unit/models/delta_extras_spec.rb +14 -0
  28. data/spec/unit/models/error_info_spec.rb +17 -1
  29. data/spec/unit/models/message_spec.rb +24 -0
  30. data/spec/unit/models/protocol_message_spec.rb +24 -20
  31. data/spec/unit/realtime/channel_spec.rb +2 -1
  32. data/spec/unit/realtime/channels_spec.rb +3 -3
  33. data/spec/unit/rest/channel_spec.rb +40 -7
  34. data/spec/unit/rest/client_spec.rb +27 -0
  35. metadata +7 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 99da4e4f2a2934965e19a4541968e651405886d6a0814786e701fc182d6e10ef
4
- data.tar.gz: f026b079b0b8969df7efe18e99413bc7d79035c2a055c46d2166d12da1d8a8ef
3
+ metadata.gz: ba8f2b01b35fceead7297645f54cb854017e14c8a004882d5b414becc450feef
4
+ data.tar.gz: c116cce13d8ed06a9858e252a81918530d54f15e1a20c4b3ef30e5334408ec1b
5
5
  SHA512:
6
- metadata.gz: 98ac241fc8720f4da77cabe14b8cd2c6b705c8ccac33cd2f81f9c937cb75ddba173e1f129670c0392f9f2a63e0809dba995d71700832d16efbc6aa24f5ae6ad3
7
- data.tar.gz: 74b4bc0c6aef5ed2ffccf41a432d8d4588a694ef0cad301e8163f8a4607536a382306d22fe0a349c95dbaad7080690220f788de8bb96033588b275e099663eaa
6
+ metadata.gz: e0761591d9f838201f208c3d44d8068ad77c87591e737083cab548e77a104a6d7bd2da2cc360e01ad661c33f3af09220813ad19fe7d93f6759a7a88de82180d9
7
+ data.tar.gz: ca14639736fc07b1d00323df0073b37e0e2f51d6a2681bf868173708aafd45a89fbc872d4c16c600a41ebea9488c336a5422bdddbf8b80daa912ce9ef231945c
data/CHANGELOG.md CHANGED
@@ -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)
data/COPYRIGHT CHANGED
@@ -1 +1 @@
1
- Copyright 2015-2021 Ably Real-time Ltd (ably.com)
1
+ Copyright 2015-2022 Ably Real-time Ltd (ably.com)
data/SPEC.md CHANGED
@@ -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))_
data/ably.gemspec CHANGED
@@ -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.3.0' # version lock, see config.around(:example, :event_machine) in event_machine_helper.rb
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] ||= 65536
42
- self.attributes[:max_frame_size] ||= 524288
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
- if messages.sum(&:size) > Ably::Realtime::Connection::MAX_MESSAGE_SIZE
26
- error = Ably::Exceptions::MaxMessageSizeExceeded.new("Message size exceeded #{Ably::Realtime::Connection::MAX_MESSAGE_SIZE} bytes.")
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::Channel::MAX_MESSAGE_SIZE
92
- raise Ably::Exceptions::MaxMessageSizeExceeded.new("Maximum message size exceeded #{Ably::Rest::Channel::MAX_MESSAGE_SIZE}.")
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
- MAX_FRAME_SIZE = 524288
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 > MAX_FRAME_SIZE
369
- raise Ably::Exceptions::MaxFrameSizeExceeded.new("Maximum frame size exceeded #{MAX_FRAME_SIZE} bytes.")
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 || {}
data/lib/ably/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Ably
2
- VERSION = '1.1.7'
2
+ VERSION = '1.1.8'
3
3
  PROTOCOL_VERSION = '1.1'
4
4
 
5
5
  # @api private