slack-client icon indicating copy to clipboard operation
slack-client copied to clipboard

PHP 7 RealTimeClient connection issue

Open arronwoods opened this issue 9 years ago • 7 comments

Hi,

Lib been working really well in PHP5. Gave my app a go on PHP 7 today but couldn't get it to work. As far as I can tell everything is the same, except the PHP version, has anyone else had success running the RealTimeClient in PHP7?

The WebSocket appears to be connecting, but nothing happens after that. Waiting for ->on('hello') or ->on('error') nothing happens. Eventually the react loop seems to stop and the script exits.

Will try to debug further, but not had much luck pinpointing it so far. Throwing this out there in case anyone has any suggestions?

arronwoods avatar Dec 10 '15 16:12 arronwoods

I can't verify this yet, but it could very well be an incompatibility with Devristo/phpws and PHP7. This is the package I have been using for WebSocket functionality, but the package has been sort of unmaintained for a while and has some outstanding issues.

I can look into this more, but I don't plan on fixing issues with phpws if that is the source of the problem, as I plan on rewriting the backend of this package to use Icicle anyway. See #10.

sagebind avatar Dec 10 '15 23:12 sagebind

Thanks Stephen, I'll try to take another look with fresh eyes tomorrow. Hopefully it's something trivial.

Saw #10, sounds interesting! On 10 Dec 2015 11:58 pm, "Stephen Coakley" [email protected] wrote:

I can't verify this yet, but it could very well be an incompatibility with Devristo/phpws https://github.com/Devristo/phpws and PHP7. This is the package I have been using for WebSocket functionality, but the package has been sort of unmaintained for a while and has some outstanding issues.

I can look into this more, but I don't plan on fixing this issue if that is the source of the problem, as I plan on rewriting the backend of the package to use Icicle anyway. See #10 https://github.com/coderstephen/slack-client/issues/10.

— Reply to this email directly or view it on GitHub https://github.com/coderstephen/slack-client/issues/14#issuecomment-163790494 .

arronwoods avatar Dec 11 '15 00:12 arronwoods

Yup, looks like an issue in Devristo/phpws. The connection is fine, and messages are received, but as far as I can tell they aren't being decoded properly. None of the "frames" are ever marked as final, and so the messages aren't emitted to slack-client.

Trying to figure out which bit is going wrong, and will open an issue upstream.

This is what I'm seeing with some hacky debugging messages in Devristo\Phpws\Protocol\WebSocketTransportHybi:

string(19) "connector handshake"
string(27) "connector transport connect"
string(10) "handleData"
string(18) "�{"type":"hello"}"
string(27) "creating message from frame"
string(20) "message taking frame"
string(20) "message taking frame"
string(20) "message taking frame"
string(20) "message taking frame"
string(20) "message taking frame"
string(20) "message taking frame"
string(20) "message taking frame"
string(20) "message taking frame"
string(10) "handleData"
string(67) "�A{"type":"presence_change","user":"U0FBK5BJQ","presence":"active"}"
string(20) "message taking frame"
string(20) "message taking frame"
string(20) "message taking frame"
string(20) "message taking frame"
string(20) "message taking frame"

arronwoods avatar Dec 11 '15 11:12 arronwoods

Found the issue, list() does not unpack in PHP7. Opened issue upstream https://github.com/Devristo/phpws/pull/76

If that project is dead, would you consider using a forked version until #10?

(Many thanks for your help and the lib btw!)

arronwoods avatar Dec 11 '15 11:12 arronwoods

Yeah, I'd be willing to use a forked version. It's not like the original project even has any stable releases anyway...

sagebind avatar Dec 11 '15 17:12 sagebind

I'll run the tests and then maybe slack-client could use https://github.com/rb-cohen/phpws for now? I suppose I'd need to rename the composer name for packagist and tag a version?

I'll look at removing the Zend\Logger requirements first too.

arronwoods avatar Dec 14 '15 09:12 arronwoods

This should be fixed by running composer update Devristo/phpws to update composer.lock. I don't have time to do that right now.

leoskyrocker avatar Apr 22 '16 21:04 leoskyrocker