Hi Team,
I tried to use the JSON option to receive the JSON format messages over the chanwebsocket
but i am receiving the text format only i do set that configuration on the chan_websocket.conf file and also i am sending the transport_data value to JSON still on the socket server i am receiving the Text message can you help me is there anything i am doing wrong
PFA for the Configuration That i have done
/etc/asterisk/chan_websocket.conf :
; Configuration for chan_websocket
;
;[general]
control_message_format = json ; The format for the control messages sent
; and received on the websocket.
; plain-text: The legacy single-line message
; format.
; json: All messages are properly formatted
; JSON.
; Default: plain-text
And
/etc/asterisk/websocket_client.conf
[ace_media_ws] ; connection id (referenced in ARI as "connection")
type = websocket_client
uri = ws://192.XXXXX:6668 ; use wss://... in production with TLS
protocols = media ; MUST be "media" for media-over-WS
connection_type = per_call_config
connection_timeout = 1000
reconnect_interval = 500
reconnect_attempts = 10
; Uncomment if using TLS
; tls_enabled = yes
; Uncomment if your WS server requires auth
; username = mediauser
; password = secret
and code
async function createExternalMediaChannel(externalMediaId, channel) {
return await channel.externalMedia(
{
channelId : externalMediaId,
app : `${constants.CALL_TYPE},chanType:streaming`,
external_host : 'ace_media_ws',
format : "slin16",
transport : "websocket",
encapsulation : "none",
connection_type: "client",
direction : "both",
transport_data : "json"
});
}

asterisk -rvvv logs
and socket server logs
Received text message: MEDIA_START connection_id:ace_media_ws channel:WebSocket/ace_media_ws/0x7304e0009b20 channel_id:c5b84cc4-420d-4ec6-87d3-dc0eb68fbe68 format:slin16 optimal_frame_size:640 ptime:20
and socket server code
import { WebSocketServer } from 'ws';
const PORT = 6668;
// Create WebSocket server
const wss = new WebSocketServer({ port: PORT });
console.log(`WebSocket server running on ws://localhost:${PORT}`);
wss.on('connection', (ws, request) => {
const clientIp = request.socket.remoteAddress;
console.log(`New client connected from ${clientIp}`);
// Handle incoming messages (text + binary)
ws.on('message', (data, isBinary) => {
if (isBinary) {
console.log(`Received binary message (${data.length} bytes)`);
// data is a Buffer
// Example: console.log(data);
} else {
console.log("FUCKKKK",data);
const message = data.toString();
console.log(`Received text message:`, message);
}
});
// Handle errors
ws.on('error', (err) => {
console.error('WebSocket error:', err);
});
// Handle close
ws.on('close', (code, reason) => {
console.log(
`Client disconnected. Code=${code}, Reason=${reason.toString()}`
);
});
// Optional: send a welcome message
});
// Server-level error handling
wss.on('error', (err) => {
console.error('WebSocket Server error:', err);
});
can yo guys help me