JMeter-WebSocketSampler
JMeter-WebSocketSampler copied to clipboard
cannot deal with binary data from server[fixed]
the websocketsampler doesn't print binary msg from server. how to fix it?
i have fixed it: add function in service socket, just below OnMessage(String msg), my code is like this: @OnWebSocketMessage public void onMessageBinary(byte buf[],int offset,int len) throws CharacterCodingException { synchronized (parent) { String msg =new String(buf,offset,len); log.debug("Received message: " + msg); String length = " (" + msg.length() + " bytes)"; logMessage.append(" - Received message #").append(messageCounter).append(length); addResponseMessage("[Message " + (messageCounter++) + "]\n" + msg + "\n\n");
if (responseExpression == null || responseExpression.matcher(msg).find()) {
logMessage.append("; matched response pattern").append("\n");
closeLatch.countDown();
} else if (!disconnectPattern.isEmpty() && disconnectExpression.matcher(msg).find()) {
logMessage.append("; matched connection close pattern").append("\n");
closeLatch.countDown();
close(StatusCode.NORMAL, "JMeter closed session.");
} else {
logMessage.append("; didn't match any pattern").append("\n");
}
}
}
it works!