|
| 1 | +--- |
| 2 | +layout: single |
| 3 | +title: 'Upgrading to stompjs@6, rx-stomp@1, ng2-stompjs@8' |
| 4 | +date: 2020-10-21 22:21:09 +0530 |
| 5 | +categories: guide stompjs rx-stomp |
| 6 | +toc: true |
| 7 | +--- |
| 8 | + |
| 9 | +These releases are synchronized releases and add similar changes. |
| 10 | +It is expected that these releases are fully backwards compatible, |
| 11 | +however, you may need to recompile your code. |
| 12 | + |
| 13 | +## User visible changes |
| 14 | + |
| 15 | +### discardWebsocketOnCommFailure |
| 16 | + |
| 17 | +Websocket specification does not provide any mechanism for quickly |
| 18 | +dropping a connection. |
| 19 | +If the underlying connection is dropped and the incoming pings fail, |
| 20 | +actual closure of the Websocket may take significant time (several minutes). |
| 21 | +This new option discards the websocket immediately. |
| 22 | +This will allow a quicker reconnection. |
| 23 | + |
| 24 | +Under the hood if the Websocket library supports `terminate` method |
| 25 | +(which `ws` npm package does), it will call that to quickly drop |
| 26 | +the connection. |
| 27 | +None of the Web browsers support any equivalent method. |
| 28 | + |
| 29 | +In this release this flag is `off` by default, set it to `true` |
| 30 | +to activate it. |
| 31 | + |
| 32 | +```typescript |
| 33 | +// Set it directly or part of configuration |
| 34 | +client.discardWebsocketOnCommFailure = true; |
| 35 | +``` |
| 36 | + |
| 37 | +### connectionTimeout |
| 38 | + |
| 39 | +The STOMP standard supports Heartbeats which allows detecting stale connections. |
| 40 | +However, this mechanism activates after a successful connection (under the hood, |
| 41 | +after `CONNECTED` STOMP frame has been received from the broker). |
| 42 | + |
| 43 | +This setting guards against the case that connection setup takes long time to |
| 44 | +establish. If it takes longer it will abandon the attempt and retry. |
| 45 | + |
| 46 | +The value is number of milliseconds to wait for a successful connection. |
| 47 | + |
| 48 | +```typescript |
| 49 | +// Set it directly or part of configuration |
| 50 | +client.connectionTimeout = 500; |
| 51 | +``` |
| 52 | + |
| 53 | +### deactivate - async |
| 54 | + |
| 55 | +You are unlikely to be affected by this change. |
| 56 | +`deactivate` has now been made `async`, if there is an underlying |
| 57 | +active connection, the call will wait till that is terminated. |
| 58 | +This prevetents a race condition that may cause more that one |
| 59 | +active underlying connection in case `deativate` and `activate` were |
| 60 | +invoked in quick succession. |
| 61 | + |
| 62 | +If you were calling `deativate` and `activate` in succession, |
| 63 | +you should await for `deativate`. |
| 64 | + |
| 65 | +## Non visible changes |
| 66 | + |
| 67 | +- The output target is `es2015`. We wanted `es2017`, however, |
| 68 | + that causes issue with Angular. |
| 69 | +- The tree shaking support is quite consistent now. |
| 70 | + In previous version `rx-stomp` used `commonjs` module system, |
| 71 | + which, was not very friendly to tree shaking. |
| 72 | +- Remove dom lib dependency for usage with NodeJS/Typescript. |
0 commit comments