Skip to content
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

RFC6455 Socket implementation incompatible with ProtocolInterface #288

Closed
PhilLehmann opened this issue Jun 14, 2023 · 1 comment
Closed

Comments

@PhilLehmann
Copy link

Hello together,

after starting my phpsocket.io-implementation ("workerman/phpsocket.io": "1.1.17" and "workerman/phpsocket.io-emitter": "1.0.2"), I receive the following output as soon as I try to connect with a call to (io('http://localhost:2020'); using "socket.io-client": "2.5.0") :

----------------------- WORKERMAN -----------------------------
Workerman version:4.1.10          PHP version:8.2.4
------------------------ WORKERS -------------------------------
worker                        listen                              processes status
PHPSocketIO          socketIO://0.0.0.0:2020             1         [ok]
PHP Fatal error:  Declaration of PHPSocketIO\Engine\Protocols\WebSocket\RFC6455::input(string $buffer, Workerman\Connection\ConnectionInterface $connection): int|bool must be compatible with Workerman\Protocols\ProtocolInterface::input($recv_buffer, Workerman\Connection\ConnectionInterface $connection) in D:\Projekte\fiddle\api\vendor\workerman\phpsocket.io\src\Engine\Protocols\WebSocket\RFC6455.php on line 47

Fatal error: Declaration of PHPSocketIO\Engine\Protocols\WebSocket\RFC6455::input(string $buffer, Workerman\Connection\ConnectionInterface $connection): int|bool must be compatible with Workerman\Protocols\ProtocolInterface::input($recv_buffer, Workerman\Connection\ConnectionInterface $connection) in D:\Projekte\fiddle\api\vendor\workerman\phpsocket.io\src\Engine\Protocols\WebSocket\RFC6455.php on line 47
Worker process terminated with ERROR: E_COMPILE_ERROR "Declaration of PHPSocketIO\Engine\Protocols\WebSocket\RFC6455::input(string $buffer, Workerman\Connection\ConnectionInterface $connection): int|bool must be compatible with Workerman\Protocols\ProtocolInterface::input($recv_buffer, Workerman\Connection\ConnectionInterface $connection) in D:\Projekte\fiddle\api\vendor\workerman\phpsocket.io\src\Engine\Protocols\WebSocket\RFC6455.php on line 47"

In a little bit more readable format:

Declaration of 
PHPSocketIO\Engine\Protocols\WebSocket\RFC6455::input(string $buffer, Workerman\Connection\ConnectionInterface $connection): int|bool 
must be compatible with 
         Workerman\Protocols\ProtocolInterface::input($recv_buffer, Workerman\Connection\ConnectionInterface $connection)
in 
		 <...>\vendor\workerman\phpsocket.io\src\Engine\Protocols\WebSocket\RFC6455.php 
on line 47

Am I doing something wrong? To be honest it just looks like a book that everyone should stumble upon.

@PhilLehmann
Copy link
Author

PhilLehmann commented Jun 14, 2023

Basically, only the types for the first parameters of the following three methods were missing. When I add them locally in file workerman\workerman\Protocols\ProtocolInterface.php, it works fine:

interface ProtocolInterface
{
    /**
     * Check the integrity of the package.
     * Please return the length of package.
     * If length is unknow please return 0 that mean wating more data.
     * If the package has something wrong please return false the connection will be closed.
     *
     * @param string              $recv_buffer
     * @param ConnectionInterface $connection
     * @return int|false
     */
    public static function input(string $recv_buffer, ConnectionInterface $connection);

    /**
     * Decode package and emit onMessage($message) callback, $message is the result that decode returned.
     *
     * @param string              $recv_buffer
     * @param ConnectionInterface $connection
     * @return mixed
     */
    public static function decode(string $recv_buffer, ConnectionInterface $connection);

    /**
     * Encode package brefore sending to client.
     * 
     * @param mixed               $data
     * @param ConnectionInterface $connection
     * @return string
     */
    public static function encode(mixed $data, ConnectionInterface $connection);
}

@walkor walkor closed this as completed in b89b3f2 Jun 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant