No header information in web socket sampler like HTTP header manager in HTTP sampler
how to add header information with websocket sampler like http sampler.i want to send request with some header information with it to the server..but there is no way to add header in web socket sampler
how can we add header like HTTP header manger in web socket sampler.?
You can use HeaderManager for changing the request headers. 1)Add this code in the source WebSocketSampler.java
private void fillHttpHeadersElement(ClientUpgradeRequest request) { JMeterProperty property = JMeterContextService.getContext().getCurrentSampler().getProperty("HeaderManager.headers"); ArrayList<JMeterProperty> objectValue = (ArrayList<JMeterProperty>) property.getObjectValue(); for (int i = 0; i < objectValue.size(); i++) { JMeterProperty next = objectValue.get(i); Header header = (Header) next.getObjectValue(); request.setHeader(header.getName(), header.getValue()); }
}
- In "private ServiceSocket getConnectionSocket() throws URISyntaxException, Exception" method, you can call this method (fillHttpHeadersElement) . //Start WebSocket client thread and upgrage HTTP connection webSocketClient.start(); ClientUpgradeRequest request = new ClientUpgradeRequest(); ///>>> fillHttpHeadersElement(request); ///>>> webSocketClient.connect(socket, uri, request);