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

Ping and keepAlive in Ratchet #263

Closed
SaphirAngel opened this issue Dec 12, 2014 · 12 comments
Closed

Ping and keepAlive in Ratchet #263

SaphirAngel opened this issue Dec 12, 2014 · 12 comments

Comments

@SaphirAngel
Copy link

For those who want to ping or be sure that a client is present (internet lost, mobile network). We have implemented the following functions:
Ping and keepAlive
The only requirement is to have an instance of the loop event.
The commit is here : 6da3b04
Repo : https://github.com/bjtpartners/Ratchet/tree/ping-dev

There are no problem found at this time for and it's very reactive.
I will not make pull request because i use the Promise and Event Loop in Ratchet directly but i share the solution :).

If you are opinions or remarks, you're welcome :).

Just a quick question : Is there a way to get the loop event from the instance of a connection ? I have not found but you never know.

Bye :)

@cboden cboden changed the title Ping and keepAlive in ratchet Ping and keepAlive in Ratchet Dec 12, 2014
@SaphirAngel
Copy link
Author

Thanks for tag.

Modification of last time.
I found for put the loop directly in IoConnection instance (simple but i misread).
I clean the code too (one day I will learn to code in php xD).
Commit : fe96e6b

More simple :).

And I also forgot: Thanks for Ratchet ! ;)

@cboden
Copy link
Member

cboden commented Dec 12, 2014

Nice work @SaphirAngel, thanks for sharing! I'll keep this issue open for people to check out. This functionality is something I'll add to the core once v0.2 of the RFC6455 library has been refactored.

@SaphirAngel
Copy link
Author

It's a pleasure ! Good announcement for this functionality in core, good luck for development ! :)

@fedyfausto
Copy link

PHP Catchable fatal error: Argument 2 passed to Ratchet\Server\IoConnection::__construct() must be an instance of React\EventLoop\LibEventLoop, instance of React\EventLoop\StreamSelectLoop given, called in /home/pi/serverapps/chattest/php/vendor/cboden/ratchet/src/Ratchet/Server/IoServer.php on line 94 and defined in /home/pi/serverapps/chattest/php/vendor/cboden/ratchet/src/Ratchet/Server/IoConnection.php on line 19

:( i tried to apply this fix but i have this error..

@SaphirAngel
Copy link
Author

Hello,

Have you pass a EventLoop instance in the IoServer constructor ?

@fedyfausto
Copy link

this is my IoServer Class:
http://pastebin.com/t0pFZywX

this is my IoConn class:
http://pastebin.com/U7vVTpJ5

this is my server.php init:
http://pastebin.com/AjPiCf5D

and this is my app script:
http://pastebin.com/rHmYpsSj

@SaphirAngel
Copy link
Author

Oh, yes, sorry for this.
This is the problem with no test (but I do not know to do, I confessed :x).

So, the problem is that for my test, i use the libevent pecl extension.
http://socketo.me/docs/deploy

I recommend to install this extension but the problem is present and i will try to push a correction within 24 hours.
Meanwhile you can :

  • Install libevent pecl extension
  • Change the code :
    The LibEventLoop parameter requirement by a LoopInterface (
    do not forget "use React\EventLoop\LoopInterface;" in use section).

Changes must be made in the files:
Ratchet/Server/IoConnection.php
Ratchet/WebSocket/Version/RFC6455/Connection.php

Sorry and thanks for feedback

@SaphirAngel
Copy link
Author

It's ok.
I push modifications (just a changement finally).
The patch for ping accept all loop type.

@cboden cboden mentioned this issue Dec 30, 2014
@fedyfausto
Copy link

i tried to install with apt-get but dont find the package... but where can i find the update? Because i have reinstalled all Ratchet :3

@filipecoelho
Copy link

Hello everyone, I'm having connection problems that get active and this ping / pong solution would help a lot.
I tried to download version 0.4 but it seems that it is still not stable.
Any forecast for official release?

@cboden
Copy link
Member

cboden commented Jun 1, 2017

it is still not stable

Have you experienced a bug in the 0.4 branch?

@filipecoelho
Copy link

pessoal, resolvi aqui e consegui usar a versão 0.4.
porém, estou tendo problemas com o memory_limit do PHP.

@cboden cboden closed this as completed Sep 14, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants