Title: Closing connection using TLS · Issue #320 · reactphp/socket · GitHub
Open Graph Title: Closing connection using TLS · Issue #320 · reactphp/socket
X Title: Closing connection using TLS · Issue #320 · reactphp/socket
Description: When closing a connection on a server using TLS, eg: 'server.pem...
Open Graph Description: When closing a connection on a server using TLS, eg:
X Description: When closing a connection on a server using TLS, eg: <?php require __DIR__ . '/vendor/autoload.php'; $server = new React\Socket\TcpServer($port = 9900); $server = new React\Socket\Secure...
Opengraph URL: https://github.com/reactphp/socket/issues/320
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Closing connection using TLS","articleBody":"\u003c!-- Add enough information so we can understand your problem -->\n\nWhen closing a connection on a server using TLS, eg:\n```php\n\u003c?php\n\nrequire __DIR__ . '/vendor/autoload.php';\n\n$server = new React\\Socket\\TcpServer($port = 9900);\n$server = new React\\Socket\\SecureServer($server, null, [\n 'local_cert' => 'server.pem',\n 'passphrase' => 'secret'\n]);\n\n$server->on('connection', function (React\\Socket\\ConnectionInterface $connection) {\n echo '[' . $connection->getRemoteAddress() . ' connected]' . PHP_EOL;\n\n // do stuff\n \n $connection->end();\n});\n```\n\nthe connection is not closed properly, as https://github.com/reactphp/socket/blob/e04478a14b22c2f85697b917dcc26fa8f1654098/src/Connection.php#L123-L133\nuses https://www.php.net/manual/en/function.stream-socket-shutdown.php.\n\nNote comment https://www.php.net/manual/en/function.stream-socket-shutdown.php#125659 which states tls does not get shut down properly that way.\n\nSolution seems to be to replace `@\\stream_socket_shutdown($this->stream, \\STREAM_SHUT_RDWR); ` with `\\fclose($this->stream)`.\n\nOther solution seems to be to call `@\\stream_socket_enable_crypto($this->stream, false);` before the socket shutdown as mentioned in comment https://www.php.net/manual/en/function.stream-socket-shutdown.php#126303","author":{"url":"https://github.com/dododedodonl","@type":"Person","name":"dododedodonl"},"datePublished":"2025-02-18T01:13:54Z","url":"https://github.com/reactphp/socket/issues/320"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:021436b7-81a8-bf2f-5638-f946c3ee39f4 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CC56:12476C:26AFDCD:332DB73:6B00575B |
| html-safe-nonce | 2f241aa9e20e9c187295775c0cabfc747a1be8f08d24c870649e9aa4daad929c |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDQzU2OjEyNDc2QzoyNkFGRENEOjMzMkRCNzM6NkIwMDU3NUIiLCJ2aXNpdG9yX2lkIjoiNzU2NzI5Nzc5OTY3MTI3MzMwNyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 399ca6d8f147bf9e7fb585cba8b49a567354936d007407349af9e516da369c82 |
| hovercard-subject-tag | issue:2859069996 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/reactphp/socket/320/issue_layout |
| twitter:image | https://opengraph.githubassets.com/eae0e4fe9d278673aa6b96fdf1e5712414cb013a4769d8f9d5356718af19054e/reactphp/socket/issues/320 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/eae0e4fe9d278673aa6b96fdf1e5712414cb013a4769d8f9d5356718af19054e/reactphp/socket/issues/320 |
| og:image:alt | When closing a connection on a server using TLS, eg: |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | dododedodonl |
| hostname | github.com |
| expected-hostname | github.com |
| None | f420f4996e6b1ff1ccd6d7683f8134f4b5f0f8a50124c210dbfe7490e5644abb |
| turbo-cache-control | no-preview |
| go-import | github.com/reactphp/socket git https://github.com/reactphp/socket.git |
| octolytics-dimension-user_id | 1696866 |
| octolytics-dimension-user_login | reactphp |
| octolytics-dimension-repository_id | 4287591 |
| octolytics-dimension-repository_nwo | reactphp/socket |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 4287591 |
| octolytics-dimension-repository_network_root_nwo | reactphp/socket |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 26e00df917aba0f128135dc073ea0c5e33a70d40 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width