[asterisk-bugs] [JIRA] (ASTERISK-28958) Continue reading string when ping received by websocket
Kevin Harwell (JIRA)
noreply at issues.asterisk.org
Mon Jun 22 12:04:25 CDT 2020
[ https://issues.asterisk.org/jira/browse/ASTERISK-28958?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Kevin Harwell updated ASTERISK-28958:
-------------------------------------
Description:
While implementing websocket-based speech recognition server https://github.com/alphacep/vosk-asterisk I had the following issue.
According to websocket specification client can receive ping control frame any time. In that case the following error is thrown by client reading for the string when client uses ast_websocket_read_string (https://github.com/asterisk/asterisk/blob/9445dac43b68ea3adff9c52cd8722f0adb86c079/res/res_http_websocket.c#L1439):
{code}
if (opcode != AST_WEBSOCKET_OPCODE_TEXT) {
ast_log(LOG_ERROR, "Client WebSocket string read - "
"non string data received\n");
return -1;
}
{code}
The proposed change should solve this problem by continue reading the string after ping is recieved:
**edit by [~kharwell]: removed inline patch.
was:
While implementing websocket-based speech recognition server https://github.com/alphacep/vosk-asterisk I had the following issue.
According to websocket specification client can receive ping control frame any time. In that case the following error is thrown by client reading for the string when client uses ast_websocket_read_string (https://github.com/asterisk/asterisk/blob/9445dac43b68ea3adff9c52cd8722f0adb86c079/res/res_http_websocket.c#L1439):
{code}
if (opcode != AST_WEBSOCKET_OPCODE_TEXT) {
ast_log(LOG_ERROR, "Client WebSocket string read - "
"non string data received\n");
return -1;
}
{code}
The proposed change should solve this problem by continue reading the string after ping is recieved:
{code}
@@ -1435,6 +1435,12 @@ int AST_OPTIONAL_API_NAME(ast_websocket_
return -1;
}
+ if (opcode == AST_WEBSOCKET_OPCODE_PING) {
+ /* Try again, we have sent pong already */
+ fragmented = 1;
+ continue;
+ }
+
if (opcode == AST_WEBSOCKET_OPCODE_CONTINUATION) {
continue;
}
{code}
> Continue reading string when ping received by websocket
> -------------------------------------------------------
>
> Key: ASTERISK-28958
> URL: https://issues.asterisk.org/jira/browse/ASTERISK-28958
> Project: Asterisk
> Issue Type: Improvement
> Security Level: None
> Components: Resources/res_http_websocket
> Affects Versions: GIT
> Reporter: Nickolay V. Shmyrev
> Severity: Minor
>
> While implementing websocket-based speech recognition server https://github.com/alphacep/vosk-asterisk I had the following issue.
> According to websocket specification client can receive ping control frame any time. In that case the following error is thrown by client reading for the string when client uses ast_websocket_read_string (https://github.com/asterisk/asterisk/blob/9445dac43b68ea3adff9c52cd8722f0adb86c079/res/res_http_websocket.c#L1439):
> {code}
> if (opcode != AST_WEBSOCKET_OPCODE_TEXT) {
> ast_log(LOG_ERROR, "Client WebSocket string read - "
> "non string data received\n");
> return -1;
> }
> {code}
> The proposed change should solve this problem by continue reading the string after ping is recieved:
> **edit by [~kharwell]: removed inline patch.
--
This message was sent by Atlassian JIRA
(v6.2#6252)
More information about the asterisk-bugs
mailing list