-
Notifications
You must be signed in to change notification settings - Fork 85
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
Pawl closing connection with code 1006 instead of 1000 #61
Comments
hmm, this is a little puzzling the fact that is happens with 2 different servers... The logic is in fact in Pawl, not the RFC lib. 1006 is supposed to be issued if the underlying socket is closed without the upper WebSocket doing a closing handshake first...
-- As I was writing that I can see a scenario where this breaks: If the However, with the above theory I wrote I would expect your |
No, the |
The PR didn't fully fix the problem. Pawl is being impatient beginning the shutdown process after sending its close frame before it has received the ack from the server. The node example doesn't like this. I'll need to do another PR with a timeout that will end the connection after sending in case the server doesn't sever the connection. |
From https://tools.ietf.org/html/rfc6455#section-7.1.1:
I'll work on another PR to inject an EventLoop into WebSocket and only close the underlying TCP connection if the server hasn't done so after a protocol Close initiation after a period of time. |
The mentioned PR does work for Discord. ;) |
v0.3.1 has been released with this fix |
@cboden Thanks for I'm using
Do you think that's what I'm experiencing with this problem here? Do you have any recommendations for me? E.g. should I try #67 (comment)? Thanks. I really appreciate your work. |
@mbonneau You helped me solve this problem 21 days ago, and I really appreciate it. I haven't been able to make progress since then. I'm still stuck getting a 1006 error code every time I send an mp3 larger than ~23 MB / 66 mins. (For shorter mp3s, it always works.) I'm even following your advice to someone else and using public function getTextFromAudio($audioFileContents, $contentType, $accessToken, $callback) {
$this->listening = false;
$this->responseJson = null;
$url = \me\Tools\SystemTools::getUrlWithUpdatedParams(self::WS_HOST . self::WS_PATH, [
'model' => 'en-US_NarrowbandModel',
'watson-token' => $accessToken
], \League\Uri\Ws::class);
$headers = ['X-Watson-Learning-Opt-Out' => true];
Log::debug('\Ratchet\Client\connect ' . sha1($audioFileContents));
$loop = \React\EventLoop\Factory::create();
$connector = new \Ratchet\Client\Connector($loop);
$connector($url, [], $headers)->then(function(\Ratchet\Client\WebSocket $conn) use($contentType, $audioFileContents, $callback, $loop) {
$conn->on('message', function($msg) use ($conn, $callback) {
$this->handleIncomingWebSocketMessage($msg, $conn, $callback);
});
$conn->on('close', function($code = null, $reason = null) {
Log::debug("Connection closed ({$code} - {$reason})");
});
$conn->on('error', function($error) {
Log::error("Ratchet Pawl error ({$error})");
});
$loop->addPeriodicTimer(120, function () use ($conn) {
$conn->send(new \Ratchet\RFC6455\Messaging\Frame('', true, \Ratchet\RFC6455\Messaging\Frame::OP_PING));
Log::debug('sent ping');
});
$this->startWatsonStream($conn, $contentType);
$this->sendBinaryMessage($conn, $audioFileContents);
Log::debug('send action stop');
$conn->send(json_encode(['action' => 'stop']));
}, function (\Exception $e) use ($loop) {
Log::error("Could not connect: {$e->getMessage()} " . $e->getTraceAsString());
$loop->stop();
});
$loop->run();
} If my understanding is correct that 1006 is always a client-side issue, it means that I'm not properly using I'm wondering if you see anything that I'm doing wrong. What would you look into? I really appreciate all of your help! |
it's not fixed. I am still getting this error in the latest version 0.3.5. I am not calling close explicitly, but after keeping it alive for about 3-4 hours socket gets closed with 1006. |
When I try to close the websocket connection with a close code 1000 (close normal), then Pawl instead disconnects with a close code 1006 (close abnormal). I've found this issue while fiddling with the Discord API and the bot account still stayed online as opposed of showing as offline. So I've fiddled a simple Node.js websocket server which dumps the close code.
PHP code:
JS code:
Logged gets the following:
PHP:
JS:
I believe this is an issue with ratchetphp/rfc6455, but I thought I will post this issue in ratchetphp/pawl, as this is the library I use. Feel free to open an issue in rfc6455 and reference this issue. I will try digging some deeper into this issue.
The text was updated successfully, but these errors were encountered: