Closed Dumbris closed 10 years ago
Thanks.. Ill look into it.
Something like this?
Caught RangeError: value 138
dart:core-patch/string_patch.dart 234 _StringBase.substring
package:stompdart/frame.dart 95:28 Frame.unmarshallSingle
package:stompdart/frame.dart 124:36 Frame.unmarshall
package:stompdart/stomp.dart 194:43 Client.connect.<fn>
dart:async/zone.dart 730 _rootRunUnary
dart:async/zone.dart 462 _ZoneDelegate.runUnary
dart:async/zone.dart 667 _CustomizedZone.runUnary
dart:async/zone.dart 582 _BaseZone.runUnaryGuarded
dart:async/stream_impl.dart 333 _BufferingStreamSubscription._sendData
dart:async/stream_impl.dart 585 _DelayedData.perform
dart:async/stream_impl.dart 701 _StreamImplEvents.handleNext
dart:async/stream_impl.dart 661 _PendingEvents.schedule.<fn>
dart:async/zone.dart 719 _rootRun
dart:async/zone.dart 453 _ZoneDelegate.run
dart:async/zone.dart 663 _CustomizedZone.run
dart:async/zone.dart 574 _BaseZone.runGuarded
dart:async/zone.dart 599 _BaseZone.bindCallback.<fn>
dart:async/zone.dart 723 _rootRun
dart:async/zone.dart 453 _ZoneDelegate.run
dart:async/zone.dart 663 _CustomizedZone.run
dart:async/zone.dart 574 _BaseZone.runGuarded
dart:async/zone.dart 599 _BaseZone.bindCallback.<fn>
dart:async/schedule_microtask.dart 23 _asyncRunCallbackLoop
dart:async/schedule_microtask.dart 32 _asyncRunCallback
dart:isolate-patch/isolate_patch.dart 128 _RawReceivePortImpl._handleMessage
Im wondering how this doesn't cause an error in stomp-websocket as it is basically copied from their source.
They have this in CoffeScript:
if headers['content-length']
len = parseInt headers['content-length']
body = ('' + data).substring(start, start + len)
else
...
Ref: https://github.com/jmesnil/stomp-websocket/blob/master/src/stomp.coffee#L80
Dart counterpart:
if (headers.containsKey("content-length")) {
int len = int.parse(headers["content-length"]);
body = data.substring(start, start + len);
} else {
...
Both data vars are Strings.
The code handling the content-length header when messages are received needs to be reimplemented. I created a new issue for that: https://github.com/Apaq/StompDart/issues/10
Meanwhile I have disabled the content-length header support - but messages should be parsed nicely anyway.
Updated version works ok, without exception. Thank you, Michael!
I have been getting reproducible RangeError exception, during processing message with utf-8 chars.
In frame.dart line 95 body = data.substring(start, start + len);
data string looks correctly in DartEditor debugger, but data.length gives wrong size. See full dump of message below.
I suppose, required to call UTF8.decode() on recieved message. But message must be byte-array in this case. I can't figure out now, where to place UTF8.decode() Dump of message frame