JMeter-WebSocketSampler icon indicating copy to clipboard operation
JMeter-WebSocketSampler copied to clipboard

cannot deal with binary data from server[fixed]

Open johnny1952 opened this issue 10 years ago • 1 comments

the websocketsampler doesn't print binary msg from server. how to fix it?

johnny1952 avatar May 22 '15 06:05 johnny1952

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!

johnny1952 avatar May 22 '15 08:05 johnny1952