-
-
Notifications
You must be signed in to change notification settings - Fork 9
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
SCM_RIGHTS issue for Windows in TransferSocket class #15
Comments
I figured it out. Windows requires a different approach to implement something similar. I tried to do it using your library as a base. It turned out pretty well!!! I had to change the architecture, and unlike UNIX, Win64 uses a process that accepts the connection and forwards it to another process, not the original socket being listened to, but the socket of the client connection. But the overall performance of this solution is also remarkable!!! Compared to Swoole, it loses only about 15%. And this is C++ code we're talking about. We can try it here: https://github.com/EdmondDantes/ampCluster |
@EdmondDantes Do you have a code sample for the original issue? IIRC, socket transfer has mainly been developed for macOS, because it doesn't support multiple processes binding to the same address / port in load balancing mode. On macOS, always the latest bind receives new connections, so it can be used for rolling restarts, but not for load balancing. Windows does support multiple processes binding to the same address / port in load balancing mode, so socket passing should rarely be necessary. |
parent.php
child.php
Windows 10.
If you try to run the code from the examples,
It leads to: Perhaps you're right that I need to create the socket in such a way that it's in SHARED mode between processes. I'll try this approach. |
I try
And it's send requests only to first worker |
It seems that socket passing algorithm is not possible for the Windows platform, as Windows does not support constants like SCM_RIGHTS. If I understand correctly, is there another approach that needs to be used here? Or perhaps it's not necessary to pass the socket in this way at all?
OS: Windows 11
PHP: PHP 8.3.4 (cli)
Log:
The transfer socket threw an exception: Undefined constant "SCM_RIGHTS"::C:\work\ct\cluster\vendor\amphp\cluster\src\Internal\StreamResourceReceivePipe.php:72
Failed sending request to bind server socket: Sending on the channel failed. Did the context die?::C:\work\ct\cluster\vendor\amphp\cluster\src\ServerSocketPipeFactory.php:65
The transfer socket threw an exception: Undefined constant "SCM_RIGHTS"::C:\work\ct\cluster\vendor\amphp\cluster\src\Internal\StreamResourceReceivePipe.php:72
The transfer socket threw an exception: Undefined constant "SCM_RIGHTS"::C:\work\ct\cluster\vendor\amphp\cluster\src\Internal\StreamResourceReceivePipe.php:72
The text was updated successfully, but these errors were encountered: