I am trying to build Native android application for video streaming. I able receive the message from web to app but facing the problem while sending. I didn’t get any reference of android code or doc to get the json format to send the message. Please share any code or doc reference for send message.
this.websocket.sendText(FINAL_OBJ.toString());
JSON format:
{
“id”: 9,
“method”: “sendMessage”,
“params”: {
“data”: {
“to”: [
“con_EBVBdlMaPB”,
“con_Lv77nwZQ4F”
],
“message”: “text message”,
“type”: 8,
“sender”: “1049”
},
“message”: {
“to”: [
“con_EBVBdlMaPB”,
“con_Lv77nwZQ4F”
],
“message”: “text message”,
“type”: 8,
“sender”: “1049”
},
“messageid”: 8,
“type”: “signal:chat”,
“sender”: “1049”
},
“jsonrpc”: “2.0”
}
Getting some exception in server logs when I send the above JSON:
The JSON you pasted here is not valid and it won’t be aceppted. Send a valid JSON and it will work.
Hi Santos, please share the valid JSON to send messages. To send from Native Android App to Web application
1 Like
@CSantosM , can you please share the valid JSON format, I didn’t get any doc reference for what all parameter to pass.
1 Like
Hi @CSantosM, I have gone through the suggested documentation, but I am not able to find the solution to send the message from Android App to Web App. Please help me with more details, or the format of the JSON, which has to be sent from Android App.
The validation process using the JSON Formatter & Validator tool fails.
You can use this website for construct a valid JSON and check if that is the unique error in your code.
Hi @pabloFuente, @CSantosM,
As I checked, the JSON format is valid. But we are facing an issue with the Payload which is sent from Android App. Please help with the Payload (the exact Keys and Values).
openvidu-openvidu-server-1 | [ERROR] 2022-11-18 06:21:42,816 [SessionHandler-3qok5onmifq32bpsab1i5n1cdo-e68-t0] org.kurento.jsonrpc.internal.JsonRpcHandlerManager - Exception while processing request {“id”:9,“method”:“sendMessage”,“params”:{“to”:[“ses_TSvtQ3Ioqu”],“data”:“hguh”,“message”:{“to”:[“ses_TSvtQ3Ioqu”],“data”:“hguh”,“type”:“1”,“sender”:“1049”},“type”:“1”,“sender”:“1049”},“jsonrpc”:“2.0”}
openvidu-openvidu-server-1 | java.lang.UnsupportedOperationException: JsonObject
openvidu-openvidu-server-1 | at com.google.gson.JsonElement.getAsString(JsonElement.java:179)
openvidu-openvidu-server-1 | at io.openvidu.server.rpc.RpcHandler.getStringParam(RpcHandler.java:814)
openvidu-openvidu-server-1 | at io.openvidu.server.rpc.RpcHandler.sendMessage(RpcHandler.java:437)
openvidu-openvidu-server-1 | at io.openvidu.server.rpc.RpcHandler.handleRequest(RpcHandler.java:147)
openvidu-openvidu-server-1 | at org.kurento.jsonrpc.internal.JsonRpcHandlerManager.handleRequest(JsonRpcHandlerManager.java:142)
openvidu-openvidu-server-1 | at org.kurento.jsonrpc.internal.server.ProtocolManager$3.run(ProtocolManager.java:218)
openvidu-openvidu-server-1 | at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
openvidu-openvidu-server-1 | at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
openvidu-openvidu-server-1 | at java.base/java.lang.Thread.run(Thread.java:829)
openvidu-openvidu-server-1 | [INFO] 2022-11-18 06:21:44,962 [AbstractJsonRpcClientWebSocket-reqResEventExec-e2-t240] io.openvidu.server.kurento.core.KurentoParticipantEndpointConfig - KMS event [IceComponentStateChange]: → endpoint: con_Gr5q8G1AFR_str_CAM_O8V4_con_JHoYsUHJtp (subscriber) | state: FAILED | componentId: 2 | streamId: 1 | timestamp: 1668752504962
openvidu-openvidu-server-1 | [INFO] 2022-11-18 06:21:45,559 [SessionHandler-dul98u505gc88bh5t3lmd7nkk5-e70-t0] io.openvidu.server.rpc.RpcHandler - Participant con_JHoYsUHJtp is calling method ‘videoData’ in session ses_TSvtQ3Ioqu
We are getting this error in the server. Please help
i.e.,
openvidu-openvidu-server-1 | [ERROR] 2022-11-18 06:21:42,816 [SessionHandler-3qok5onmifq32bpsab1i5n1cdo-e68-t0] org.kurento.jsonrpc.internal.JsonRpcHandlerManager - Exception while processing request {“id”:9,“method”:“sendMessage”,“params”:{“to”:[“ses_TSvtQ3Ioqu”],“data”:“hguh”,“message”:{“to”:[“ses_TSvtQ3Ioqu”],“data”:“hguh”,“type”:“1”,“sender”:“1049”},“type”:“1”,“sender”:“1049”},“jsonrpc”:“2.0”}
Android code for reference
Did you solve the issue? I’m facing the same problem
Can you please provide the correct message JSON. Thank you
I just soled the problem
Map<String, String> message = new HashMap<>();
message.put("message", "{\"to\":[],\"data\":\""+String.valueOf(text you want to send)+"\",\"type\":\"signal:chat\"}");
webSocket.sendJson(JsonConstants.SENDMESSAGE_ROOM_METHOD, message);