I want to use JMeter with the Plugin maciejzaleski/JMeter-WebSocketSampler to make some websocket tests.
At the server side I have running a tomcat with a java websocket endpoint. So I'm using the websocket library from the tomcat 8.0.
In my test I send with the jmeter sampler a request message with a number to the server. If the OnMessage event is fired, I use the number to read a number of datasets out of a mongodb. After reading the datasets I want to send them back to jmeter. It works like a echo server.
@OnMessage
public void echo(int message, Session session) throws IOException{
System.out.println("Client message: " + message);
int limit=0;
limit = message;
//connect to mongoDB
//MongoClient client = new MongoClient("localhost",27017);
mongo = new MongoAccess(client);
//start time reading data
long timeOne = System.currentTimeMillis();
System.out.println("Time One:" + timeOne + "ms");
//read data from mongoDB
String data= mongo.readNumberOfDocuments(limit).toString();
//end time reading data
long timeTwo = System.currentTimeMillis();
System.out.println("Time Two:" + timeTwo + "ms");
System.out.println("Read Time Mongo: " + (timeTwo-timeOne) + "ms");
//send data to client
session.getBasicRemote().sendText("DB Time:" + (timeTwo-timeOne)+"ms "+data);
//close connection to mongoDB
client.close();
//Logging read times from mongo db
logReadTime(timeOne,timeTwo,"OnMessage");
}
If I send the number 100 for 100 datasets and use the loop one time it works fine. But if I want more datasets like 1000 or use in the loop 100 it doesn't work. My tomcat throws exceptions like this.
And the server can send only 113 datasets instead of 1000 because the connection is closed bevor the datasets can arrive.
My goal is to send different numbers of datasets over the websocket connection and change the number of loops. For example I want to send 100 times a request and receive 1000 datasets to jmeter. Additionally I want to simulate different numbers of users. So I want to analyse the different response times.
I think the problem is on the jmeter side because with a simple websocket client in my browser I have no problems....
Any ideas what I did wrong? How can I test something like that with Jmeter?