2

I am attempting to test a node.js app that uses socket.io with artillery, however I keep getting an error even when trying to parse the simplest of files. For example, this is my .yaml:

config:
  target: 'localhost'
  phases:
    - duration: 10
      arrivalRate: 1
scenarios:
  - name: "asd"
  - flow:
    - emit:
        channel: 'enterGame'

And I keep getting this error:

npm\node_modules\artillery\lib\commands\run.js:316 scenario.flow.forEach(function(step) { ^

TypeError: Cannot read property 'forEach' of undefined

How could I possibly fix this?

user10433783
  • 103
  • 7
  • 2
    looking at examples for artillery ... the `-emit:` under `- flow:` looks wrong - lack of space between `-` and `emit` (haven't YAML'd in awhile though) – Jaromanda X Sep 02 '19 at 12:04
  • I added a space, still getting the same error... I am at a loss... perhaps the artillery npm package is outdated .. – user10433783 Sep 02 '19 at 12:07
  • 1
    yeah, just checked, and it's OK syntax ... but what does "emit" do? could it need `- channel: 'enterGame'` ? – Jaromanda X Sep 02 '19 at 12:09
  • It's used to emit data from the client to the server's websocket... I'm following these examples: https://artillery.io/blog/load-testing-socketio-with-artillery In there there is no '-' before 'channel:', I tried adding it and I'm still getting the same error. – user10433783 Sep 02 '19 at 12:14
  • 1
    see how `flow:` below `- name:` has no `-` - try removing the `-` before `flow` but keep `flow` directly below `name` - as per example in the link you provided – Jaromanda X Sep 02 '19 at 12:16
  • Adding '-engine: "socketio"' seems to have fixed this error. Artillery is still not properly connecting to my server but at least it is successfully parsing the file. This is how it looks now: config: target: "localhost" phases: - duration: 10 arrivalRate: 1 scenarios: - engine: "socketio" flow: - emit: channel: "enterGame" count: 2 – user10433783 Sep 02 '19 at 12:18
  • 1
    seems like `flow:` should have `-loop` if you want `count` – Jaromanda X Sep 02 '19 at 12:19
  • Adding -loop has caused that same error to return .... – user10433783 Sep 02 '19 at 12:21
  • 1
    you also have an emit channel, with no data (I'm just going by the documentation you seem to be following) – Jaromanda X Sep 02 '19 at 12:21
  • This shouldn't be a problem since in my architecture data is not sent with this message (you can emit to sockets without sending particular data). In this case the server needs to know that a user has pressed the 'play' button, it does not expect any data to come with that. – user10433783 Sep 02 '19 at 12:25
  • `you can emit to sockets without sending particular data` - sure, but does artillery handle such a case? documentation suggests you need `data:` – Jaromanda X Sep 02 '19 at 12:27
  • 1
    try https://pastebin.com/fr7jbEyR – Jaromanda X Sep 02 '19 at 12:30
  • I tried this and a couple of other rearrangements and now it is successfully parsed but the server does not register any connections and I get this error: Error: xhr poll error: 10 According to this link https://github.com/artilleryio/artillery/issues/361 I should add transports: ["websocket"] which I did, but now I'm getting another error: Error: websocket error: 10 similar to the people commenting at the end of the link. This error seems to have no fix online so I reckon that I'll have to give up on my hopes that I can test my app with artillery.. – user10433783 Sep 02 '19 at 12:40
  • Sometimes I get websocket error: 3 and sometimes - websocket error: 7. – user10433783 Sep 02 '19 at 12:42
  • 1
    so, not the websocket error 251 in the issue – Jaromanda X Sep 02 '19 at 12:44
  • No. I presume it's related to the number of scenarios, but I have no clue. Thanks a lot for trying to help though, it's very much appreciated. – user10433783 Sep 02 '19 at 12:45
  • apparently there's no such thing as websocket errors 3, 7 or 10! I wonder if they are 1003, 1007 and 1010 instead? – Jaromanda X Sep 02 '19 at 12:48
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/198825/discussion-between-user10433783-and-jaromanda-x). – user10433783 Sep 02 '19 at 12:52
  • I moved to chat as I cannot send you the full logs here due to character count restrictions – user10433783 Sep 02 '19 at 13:02

0 Answers0