New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Websocket : 'received pong message' : Failed to convert value of type 'java.nio.HeapByteBuffer' to required type 'java.lang.String' #284

vinay-prasad opened this Issue Sep 7, 2017 · 3 comments


None yet
3 participants

vinay-prasad commented Sep 7, 2017

I have a citrus test case which uses Websockets cleint for testing. It sends some request and validates the response (JSON). What I encountered is whenever there is a Ping-Pong communication between the client and server,

  1. Citrus logs the incoming pong as "received pong message"
  2. The receive template logs an error as it can not convert the "java.nio.HeapByteBuffer" into JSON, which I think is the representation of pong response.
    This leads to the failure


  1. How can I control the ping/pong behavior from Citrus
  2. If I can not how can I filter a pong response from test response?

12:06:19,696 DEBUG nt.WebSocketConsumer| Waiting for message on 'ws://myhostname:60000' - retrying in 500 ms
12:06:19,755 DEBUG trusWebSocketHandler| WebSocket endpoint (some_client_ip:54406->some_server_ip:60000) received text message
12:06:20,148 DEBUG trusWebSocketHandler| WebSocket endpoint (some_client_ip:54406->some_server_ip:60000) received pong message
12:06:20,196 INFO nt.WebSocketConsumer| Received Web Socket message
12:06:20,196 DEBUG Logger.Message_IN| WEBSOCKETMESSAGE [payload: {"Acknowledgement":{"request":"CheckoutSessionRequest"}}][headers: {citrus_message_id=37f4473b-b803-49e4-b068-44cad4028110, citrus_message_timestamp=1504800380196, citrus_websocket_is_last=true}]
12:06:20,196 DEBUG ageValidatorRegistry| Found 3 message validators for message type: json
12:06:20,198 DEBUG Logger.Message_IN| WEBSOCKETMESSAGE [payload: java.nio.HeapByteBuffer[pos=0 lim=0 cap=0]][headers: {citrus_message_id=34e09791-2321-49ff-937c-e5b4f9224d78, citrus_me
java.nio.HeapByteBuffer[pos=0 lim=0 cap=0]][headers: {citrus_message_id=34e09791-2321-49ff-937c-e5b4f9224d78, citrus_message_timestamp=1504800380197, citrus_websocket_is_last=true}]

12:06:20,199 DEBUG ageValidatorRegistry| Found 3 message validators for message type: json
12:06:20,200 WARN .TypeConversionUtils| Using object toString representation: Failed to convert value of type 'java.nio.HeapByteBuffer' to required type 'java.lang.String'; nested exception is java.lang.IllegalStateException: Cannot convert value of type 'java.nio.HeapByteBuffer' to required type 'java.lang.String': no matching editors or conversion strategy found
12:06:20,201 INFO citrus.Citrus|
12:06:20,201 ERROR citrus.Citrus| TEST FAILED ResetEventsCheckoutXmlTest <com.test> Nested exception is:
com.consol.citrus.exceptions.CitrusRuntimeException: Failed to parse JSON text
at com.consol.citrus.validation.json.JsonTextMessageValidator.validateMessagePayload(
at com.consol.citrus.validation.json.JsonTextMessageValidator.validateMessagePayload(
at com.consol.citrus.validation.AbstractMessageValidator.validateMessage(
at com.consol.citrus.validation.AbstractMessageValidator.validateMessage(
at com.consol.citrus.actions.ReceiveMessageAction.validateMessage(
at com.consol.citrus.actions.ReceiveMessageAction.doExecute(
at com.consol.citrus.actions.AbstractTestAction.execute(
at com.consol.citrus.TestCase.executeAction(
at com.consol.citrus.TestCase.doExecute(
at com.consol.citrus.actions.AbstractTestAction.execute(
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(
at sun.reflect.DelegatingMethodAccessorImpl.invoke(
at java.lang.reflect.Method.invoke(
at org.testng.internal.MethodInvocationHelper.invokeHookable(
at org.testng.internal.Invoker.invokeMethod(
at org.testng.internal.Invoker.invokeTestMethod(
at org.testng.internal.Invoker.invokeTestMethods(
at org.testng.internal.TestMethodWorker.invokeTestMethods(
at org.testng.TestRunner.privateRun(
at org.testng.SuiteRunner.runTest(
at org.testng.SuiteRunner.runSequentially(
at org.testng.SuiteRunner.privateRun(
at org.testng.SuiteRunnerWorker.runSuite(
at org.testng.TestNG.runSuitesSequentially(
at org.testng.TestNG.runSuitesLocally(
at org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.executeSingleClass(
at org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.execute(
at org.apache.maven.surefire.testng.TestNGProvider.invoke(
at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(
at org.apache.maven.surefire.booter.ForkedBooter.main(
Caused by: net.minidev.json.parser.ParseException: Unexpected token java.nio.HeapByteBuffer[pos=0 lim=0 cap=0] at position 42.
at net.minidev.json.parser.JSONParserBase.readFirst(
at net.minidev.json.parser.JSONParserBase.parse(
at net.minidev.json.parser.JSONParserString.parse(
at net.minidev.json.parser.JSONParserString.parse(
at net.minidev.json.parser.JSONParser.parse(
at com.consol.citrus.validation.json.JsonTextMessageValidator.validateMessagePayload(
... 40 more


This comment has been minimized.


christophd commented Sep 11, 2017

The problem here is the message payload of type java.nio.HeapByteBuffer. Citrus message conversion strategy is not able to handle this type when using the JsonTextMessageValidator. Let me see how we can add the message conversion somehow.


This comment has been minimized.

mlybarger commented Nov 29, 2017

@christophd we're very interested in this feature. is there a timeframe you could comment on for the 2.7.3 release? anything we can do to help :). alternatively, is there a quick way we can use the git version of citrus framework in our pom? snapshots?.. Nevermind. I found my answer here:


This comment has been minimized.


christophd commented Nov 29, 2017

Version 2.7.3 is scheduled within the next weeks - keeping our fingers crossed! Definitely within 2017! As an alternative you can use the nightly snapshot releases 2.7.3-SNAPSHOT. These snapshots are available via Maven snapshot repository. Just add the repository to your Maven POM file


After that you will be able to use 2.7.3-SNAPSHOT in your project including the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment