We have a Websocket server which I have to load test. The test case is as follows:
- Maximum number of connections possible
- Each connections should be sending 1 message/second
Tools I have tried:
- Phantom JS (Unsuccessful)
- Apache JMeter (Partially successfully): I was able to simulate simultaneous connections. For each connection a separate thread is created. But I am only able to send one message after connecting using the plugin https://github.com/kawasima/jmeter-websocket/ the thread just remains stagnant after send that one message. I cannot create a separate thread group for sending messages as I wish to test a situation where communication takes place via the existing Websocket only. I might be missing some configuration or a rare plugin which allows me to recreate my test case.
- NeoLoad 4.2: This is the exact tool I was looking for. It allows me to perfectly create my test case BUT my company is not ready to invest in any testing tool(Forget about having a testing team either). And due to trial limitations, I am only able to simulate 10 users.
Please suggest/advice with any possible tool or plugin which will help me.
EDIT:
Here is how I managed it.
public class Tester {
static int i;
int numberOfConnections = 300; //number of simultaneous connections.
public static void main(String[] args) {
final String channel = "111";
for (i = 0; i < numberOfConnections; i++) {
try {
TimeUnit.SECONDS.sleep(3);
new Thread(new Runnable() {
@Override
public void run() {
try {
final CUstomWebsocketClientWrapper client = new CUstomWebsocketClientWrapper("http://162.243.235.172:8080", "demo", "demo");
client.createConnection(channel + i); //Open the connection
TimeUnit.SECONDS.sleep(2);
new Thread(new Runnable() {
@Override
public void run() {
while (true) {
try {
client.push(channel + i, "Message" + i); //Send message
TimeUnit.SECONDS.sleep(1); //Change message sending rate here.
} catch (InterruptedException ex) {
Logger.getLogger(Tester.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
}).start();
} catch (InterruptedException ex) {
Logger.getLogger(Tester.class.getName()).log(Level.SEVERE, null, ex);
}
}
}).start();
} catch (InterruptedException ex) {
Logger.getLogger(Tester.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
}
This will create clients sending messages at the defined rate. Make sure you have loads of RAM or you'll end up with an out of memory error. And after each test you will have to restart Tomcat/Jetty so the threads are destroyed. This is not the ideal or memory efficient way but this is the only method that works for free.