Hi,
I am attempting to create an ARI WebSocket server with a WebSocket client for media. I found this example and tried to replicate it. The main difference is in the WebSocket connection: the example connects to Asterisk, while in my case, Asterisk is connecting to my server. However, the behavior is different, and it’s not working as expected.
Here’s what I’ve observed:
-
The StasisStart event is almost identical in both examples, except for the “application” attribute:
// Example: "application": "dev_robo" // My app: "application": "dev_robo:PJSIP/virtualisk-00000001" -
I proceed to create an INCOMING channel, but in my request, I set the “app” attribute from StasisStart instead of using my Stasis app name.
-
When sending the request to create a new channel (
POST /channels/create), the example only returns aRESTResponse, whereas my app returns both a Dial event followed by theRESTResponse. The response also differs in the dialplan:// Example: "dialplan": { "context": "default", "exten": "s", "priority": 1, "app_name": "", "app_data": "" } // My app: "dialplan": { "context": "default", "exten": "s", "priority": 1, "app_name": "AppDial2", "app_data": "(Outgoing Line)" } -
When attempting to dial the newly created channel, it crashes every time with the error:
409 Conflict: Channel not in Stasis application.Here are the requests:
// Example: { "type": "RESTRequest", "request_id": "ee88bbd3-de26-4a0b-abe4-a6bf051731e2", "method": "POST", "uri": "channels/1755843534.1/dial?caller=1755843534.0&timeout=5" } // My app: { "type": "RESTRequest", "request_id": "f8d24f0134c635b86db95e0fd89af5cd", "method": "POST", "uri": "channels/1755849543.1/dial", "content_type": "application/json", "message_body": "{\"caller\":\"1755849542.0\"}" } -
The Asterisk configuration is the same in both cases.
Am I doing something wrong here? How can I create an INCOMING channel that is associated with the Stasis application?
Below is the full log of events and requests:
Example
{
"type": "StasisStart",
"timestamp": "2025-08-22T06:18:54.514+0000",
"args":
[
"incoming"
],
"channel":
{
"id": "1755843534.0",
"name": "PJSIP/virtualisk-00000000",
"state": "Ring",
"protocol_id": "0795347746b1b67a34b41d230e3db6eb@192.168.8.10:5060",
"caller":
{
"name": "Dev",
"number": "176"
},
"connected":
{
"name": "",
"number": ""
},
"accountcode": "",
"dialplan":
{
"context": "from-virtualisk",
"exten": "dev_5010",
"priority": 2,
"app_name": "Stasis",
"app_data": "dev_robo,incoming"
},
"creationtime": "2025-08-22T06:18:54.513+0000",
"language": "en",
"channelvars":
{
"MEDIA_WEBSOCKET_CONNECTION_ID": "",
"MEDIA_WEBSOCKET_OPTIMAL_FRAME_SIZE": ""
}
},
"asterisk_id": "92:00:06:45:50:b0",
"application": "dev_robo"
}
{
"type": "RESTRequest",
"request_id": "1512fbc5-e929-412e-83ee-d881b47343a3",
"method": "POST",
"uri": "channels/create",
"query_strings":
[
{
"name": "endpoint",
"value": "WebSocket/INCOMING/c(ulaw)"
},
{
"name": "app",
"value": "dev_robo"
},
{
"name": "appArgs",
"value": "websocket"
},
{
"name": "originator",
"value": "1755843534.0"
}
]
}
{
"type": "RESTResponse",
"transaction_id": "",
"request_id": "1512fbc5-e929-412e-83ee-d881b47343a3",
"status_code": 200,
"reason_phrase": "OK",
"uri": "channels/create",
"content_type": "application/json",
"message_body":
{
"id": "1755843534.1",
"name": "WebSocket/INCOMING/0x7f68e4017250",
"state": "Down",
"protocol_id": "",
"caller":
{
"name": "",
"number": ""
},
"connected":
{
"name": "",
"number": ""
},
"accountcode": "",
"dialplan":
{
"context": "default",
"exten": "s",
"priority": 1,
"app_name": "",
"app_data": ""
},
"creationtime": "2025-08-22T06:18:54.515+0000",
"language": "en",
"channelvars":
{
"MEDIA_WEBSOCKET_CONNECTION_ID": "",
"MEDIA_WEBSOCKET_OPTIMAL_FRAME_SIZE": ""
}
},
"application": "dev_robo",
"timestamp": "2025-08-22T06:18:54.516+0000",
"asterisk_id": "92:00:06:45:50:b0"
}
{
"type": "RESTRequest",
"request_id": "ee88bbd3-de26-4a0b-abe4-a6bf051731e2",
"method": "POST",
"uri": "channels/1755843534.1/dial?caller=1755843534.0&timeout=5"
}
... other events which I don't have because of crash
{
"type": "RESTResponse",
"transaction_id": "",
"request_id": "ee88bbd3-de26-4a0b-abe4-a6bf051731e2",
"status_code": 204,
"reason_phrase": "No Content",
"uri": "channels/1755843534.1/dial",
"application": "dev_robo",
"timestamp": "2025-08-22T06:18:54.519+0000",
"asterisk_id": "92:00:06:45:50:b0"
}
My app
{
"type": "StasisStart",
"timestamp": "2025-08-22T07:59:03.090+0000",
"args": [
"incoming"
],
"channel": {
"id": "1755849542.0",
"name": "PJSIP\/virtualisk-00000000",
"state": "Ring",
"protocol_id": "46ce68354a919999669ff2fc26a5bceb@192.168.8.10:5060",
"caller": {
"name": "Dev",
"number": "176"
},
"connected": {
"name": "",
"number": ""
},
"accountcode": "",
"dialplan": {
"context": "from-virtualisk",
"exten": "dev_5010",
"priority": 2,
"app_name": "Stasis",
"app_data": "dev_robo,incoming"
},
"creationtime": "2025-08-22T07:59:02.587+0000",
"language": "en",
"channelvars": {
"MEDIA_WEBSOCKET_CONNECTION_ID": "",
"MEDIA_WEBSOCKET_OPTIMAL_FRAME_SIZE": ""
}
},
"asterisk_id": "92:00:06:45:50:b0",
"application": "dev_robo:PJSIP\/virtualisk-00000000"
}
{
"type": "RESTRequest",
"request_id": "f6f2f83604328c47f8fe53c2534941e5",
"method": "POST",
"uri": "channels",
"content_type": "application\/json",
"message_body": "{\"app\":\"dev_robo:PJSIP\\\/virtualisk-00000000\",\"originator\":\"1755849542.0\",\"endpoint\":\"WebSocket\\\/INCOMING\\\/c(slin16)\"}"
}
{
"type": "Dial",
"timestamp": "2025-08-22T07:59:03.094+0000",
"dialstatus": "",
"forward": "",
"dialstring": "INCOMING\/c(slin16)",
"peer": {
"id": "1755849543.1",
"name": "WebSocket\/INCOMING\/0x7f704c014640",
"state": "Down",
"protocol_id": "",
"caller": {
"name": "",
"number": ""
},
"connected": {
"name": "Dev",
"number": "176"
},
"accountcode": "",
"dialplan": {
"context": "default",
"exten": "s",
"priority": 1,
"app_name": "AppDial2",
"app_data": "(Outgoing Line)"
},
"creationtime": "2025-08-22T07:59:03.093+0000",
"language": "en",
"channelvars": {
"MEDIA_WEBSOCKET_CONNECTION_ID": "a6778a50-c199-4f90-9d72-e8f4df1948d3",
"MEDIA_WEBSOCKET_OPTIMAL_FRAME_SIZE": "640"
}
},
"asterisk_id": "92:00:06:45:50:b0",
"application": "dev_robo:PJSIP\/virtualisk-00000000"
}
{
"type": "RESTResponse",
"transaction_id": "",
"request_id": "f6f2f83604328c47f8fe53c2534941e5",
"status_code": 200,
"reason_phrase": "OK",
"uri": "channels",
"content_type": "application\/json",
"message_body": {
"id": "1755849543.1",
"name": "WebSocket\/INCOMING\/0x7f704c014640",
"state": "Down",
"protocol_id": "",
"caller": {
"name": "",
"number": ""
},
"connected": {
"name": "Dev",
"number": "176"
},
"accountcode": "",
"dialplan": {
"context": "default",
"exten": "s",
"priority": 1,
"app_name": "AppDial2",
"app_data": "(Outgoing Line)"
},
"creationtime": "2025-08-22T07:59:03.093+0000",
"language": "en",
"channelvars": {
"MEDIA_WEBSOCKET_CONNECTION_ID": "a6778a50-c199-4f90-9d72-e8f4df1948d3",
"MEDIA_WEBSOCKET_OPTIMAL_FRAME_SIZE": "640"
}
},
"application": "dev_robo:PJSIP\/virtualisk-00000000",
"timestamp": "2025-08-22T07:59:03.094+0000",
"asterisk_id": "92:00:06:45:50:b0"
}
{
"type": "RESTRequest",
"request_id": "f8d24f0134c635b86db95e0fd89af5cd",
"method": "POST",
"uri": "channels\/1755849543.1\/dial",
"content_type": "application\/json",
"message_body": "{\"caller\":\"1755849542.0\"}"
}
{
"type": "RESTResponse",
"transaction_id": "",
"request_id": "f8d24f0134c635b86db95e0fd89af5cd",
"status_code": 409,
"reason_phrase": "Conflict",
"uri": "channels\/1755849543.1\/dial",
"content_type": "application\/json",
"message_body": {
"message": "Channel not in Stasis application"
},
"application": "dev_robo:PJSIP\/virtualisk-00000000",
"timestamp": "2025-08-22T07:59:03.137+0000",
"asterisk_id": "92:00:06:45:50:b0"
}