Skip to content

ArrayBuffer errors with large amounts of messages #55

@fbushman

Description

@fbushman

Hey,

Great library so far, but I encountered an issue that I can't explain.
A bit of background; I'm sending simulated air traffic to a browser that is displaying it in Leaflet. I'm sending info about 6000 planes, an update each 10 seconds. So about 600 messages per second. After 'some time' (seemingly random, but quicker with higher volumes) I get a pair of errors out of amqp-websocket-client.js:

ERROR TypeError: First argument to DataView constructor must be an ArrayBuffer
    at new DataView (<anonymous>)
    at AMQPWebSocketClient.handleMessage (amqp-websocket-client.js:59:38)
    at WebSocket.wrapFn (zone.js:769:39)
    at _ZoneDelegate.invokeTask (zone.js:409:31)
    at core.mjs:25299:55
    at AsyncStackTaggingZoneSpec.onInvokeTask (core.mjs:25299:36)
    at _ZoneDelegate.invokeTask (zone.js:408:60)
    at Object.onInvokeTask (core.mjs:25607:33)
    at _ZoneDelegate.invokeTask (zone.js:408:60)
    at Zone.runTask (zone.js:178:47)
ERROR RangeError: offset is out of bounds
    at Uint8Array.set (<anonymous>)
    at AMQPWebSocketClient.handleMessage (amqp-websocket-client.js:58:38)
    at WebSocket.wrapFn (zone.js:769:39)
    at _ZoneDelegate.invokeTask (zone.js:409:31)
    at core.mjs:25299:55
    at AsyncStackTaggingZoneSpec.onInvokeTask (core.mjs:25299:36)
    at _ZoneDelegate.invokeTask (zone.js:408:60)
    at Object.onInvokeTask (core.mjs:25607:33)
    at _ZoneDelegate.invokeTask (zone.js:408:60)
    at Zone.runTask (zone.js:178:47)

As far as I can tell the data is intact. I have another listener on the same exchange (this one in Java) that parses the messages just fine.

Here is the code for the consumer running in the browser:

private queue_name = uuidv4()
private queue_options = { passive: false, durable: false, autoDelete: true, exclusive: true }
private exchange_name = "exchange_name"
private exchange_type = "fanout"
private exchange_options = { passive: false, durable: true, autoDelete: false, internal: false }
private routing_key = "gps"
private subscribe_options = { noAck: false, exclusive: false }

private connectRabbitMQ() {
    const amqp = new AMQPWebSocketClient("ws://localhost:15670", "/", "rabbituser", "rabbitpassword")
    amqp.connect().then(conn => {
      conn.channel().then(channel => {
        this.rabbitmq_channel = channel
        channel.exchangeDeclare(this.exchange_name, this.exchange_type, this.exchange_options)
        channel.queue(this.queue_name, this.queue_options).then(async queue => {
          await queue.bind(this.exchange_name, this.routing_key)
          await queue.subscribe(this.subscribe_options, msg => {
            if (msg.routingKey === "track") {
              let newTrack: TrackInfo = JSON.parse(msg.bodyToString() as string) as TrackInfo;

              // Some handling...

              msg.ack();
            } else if (msg.routingKey === "plot") {
              let newPlot: PlotInfo = JSON.parse(msg.bodyToString() as string) as PlotInfo;

              // Some handling...

              msg.ack();
            } else {
              console.log(msg);
              console.log(msg.bodyToString());
            }
          })
        })
      })
    })

I am using your latest version:

"@cloudamqp/amqp-client": "^2.1.1"

Am I missing a step, or is something actually going wrong?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions