Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

socket.io in Jmeter

I studied a sample from this link http://socket.io/docs/

Example

<script src="/socket.io/socket.io.js"></script>
<script src="http://code.jquery.com/jquery-1.11.1.js"></script>        
<script>

  var socket = io('ws://127.0.0.1:3000');
  socket.emit('ui:index:loaded',{_id: '123456'});

  socket.on('app:banner:loaded',function(obj){
      console.log(obj);
  });

  socket.on('app:collection:loaded',function(obj){
      console.log(obj);
  });

</script>

How to use this in Jmeter?

Now, I request 2probe, it response 3probe.

I need to send event

Anyone have ideas.

like image 395
JMaster Avatar asked Oct 23 '25 15:10

JMaster


1 Answers

There is a super late answer for anyone still needs it.

I used Chrome dev tools and tried to see what happened when a event emitted. I found that there was a http POST request sent when emitting event, so what I did was creating a same http request by jmeter, and it works.

In my case, the event name is "join", and the content is {"sn":"1522729528413MDSCDGE","vsn":"093"}

Here is what I've found in Chrome's Network tab

And here is a HTTP Request Sampler I created by jmeter.

I think the number 52 means the string length of your event content. If you want to change your event content, remember to calculate a correct length, and I don't know what 42 means. I just copied it.

Hope this helps.

like image 54
周九三 Avatar answered Oct 26 '25 18:10

周九三



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!