artilleryio / artillery-core

artillery-core - deprecated
Mozilla Public License 2.0
29 stars 105 forks source link

Double send in socket.io engine #215

Closed rjnienaber closed 5 years ago

rjnienaber commented 6 years ago

When using Artillery the other day I ran into something that doesn't fit my mental model. My scenario looked like this:

config:
  target: "ws://localhost:3004"
  phases:
    - duration: 1
      arrivalRate: 1
scenarios:
  - name: Previous Winner
    engine: socketio
    flow:
      - emit:
          channel: "rewards.requests"
          data:
            messageType: rewards.previous_winner
            correlationId: "71efe5a9-0d92-493e-abe2-8fae5a88088b"
          response:
            channel: "rewards.response"
            match:
              - json: "$.status"
                value: "success"

Given this scenario, if I run Artillery I would expect to see a single request hit the server and then the server issue a response that is checked. However, what I see is that two requests are sent. If I remove the response matcher section, then only a single request is sent.

I've tracked this down to the following line in engine_socketio.js:

       // No acknowledge data is expected, so emit without a listener
        socketio.emit(outgoing.channel, outgoing.data);
        markEndTime(ee, context, startedAt);
        return callback(null, context);

This change seemed to have landed as part of #181 and I presume acknowledgements refers to this part of the socket.io documentation. Given in my situation I'm not looking for acknowledgements, could this line possibly be a bug? If I remove it and rerun my scenario it seems to work as I would expect.

rjnienaber commented 6 years ago

Not sure if @Demostrike has any thoughts on this.

Demostrike commented 6 years ago

I believe that code was just moved from elsewhere - does it happen prior to my commit?

rjnienaber commented 6 years ago

@Demostrike, the commit before #181 was merged seems to be 10fe5ea4. I tested it with that revision and it works as expected.