voryx / ThruwayBundle

Bundle for building Real-time Apps in Symfony
98 stars 47 forks source link

Connection lost after idle #46

Closed NewOldMax closed 6 years ago

NewOldMax commented 7 years ago

Hi! I use your bundle and autobahnjs to create real-time web app. All works fine, but after some idle time connection between client and server lost. I get on frontend:

Connection lost Object {reason: null, message: null, retry_delay: 1.54782944253703, retry_count: 1, will_retry: true}

And on backend:

php_1            | [router 0 21] 2016-10-24T12:10:32.8671780 debug      [Thruway\Peer\Router 22] onClose from {"type":"ratchet","transportAddress":"172.18.0.5"}
php_1            | 2016-10-24T12:10:32.8677610 debug      [Thruway\Role\Broker 22] Broker onMessage for {"type":"dummyTransport","transportAddress":"dummy"}: [16,298986786785729,{},"wamp.metaevent.session.on_leave",[{"realm":"sales","authprovider":null,"authid":"eyJ0eXAiOiJKV1QiLCJhbG21ciOiJIUzI1NiJ9.eyJpZCI6Ijk1YTgwN123zhjLTI1ZjEtNGYxOC05YjA1LTMwZGM1YWY5NjlkZSIsImVtYWlsIjoiYWRtaW5AZXhhbXBsZS5jb20iLCJyb2xlIjoiYWRtaW4iLCJuYW1lIjoiUmVuYXRlIiwiZmFjZWJvb2tJZCI6bnVsbCwiZ29vZ2xlSWQiOm51bGwsImxpbmtlZGluSWQiOm51bGwsImFjdGl2ZSI6dHJ1ZSwic3ViIjoidXNlciIsImV4cCI6MTQ3NzM5NzEyMX0.tPWtuPCzXlLBVGRPlI_vq9RUkjp00giwOOs4bGvxgg1","authrole":"user","authroles":["user","authenticated_user"],"authmethod":"wampcra","session":2154130370063314,"role_features":{"caller":{"features":{"caller_identification":true,"progressive_call_results":true}},"callee":{"features":{"caller_identification":true,"pattern_based_registration":true,"shared_registration":true,"progressive_call_results":true,"registration_revocation":true}},"publisher":{"features":{"publisher_identification":true,"subscriber_blackwhite_listing":true,"publisher_exclusion":true}},"subscriber":{"features":{"publisher_identification":true,"pattern_based_subscription":true,"subscription_revocation":true}}}}]]
php_1            | 2016-10-24T12:10:32.8679650 debug      [Thruway\Realm 22] Leaving realm sales
php_1            | 2016-10-24T12:10:32.8681130 info       [Thruway\Transport\RatchetTransportProvider 22] Ratchet has closed
php_1            | [router 0 21] 2016-10-24T12:10:35.0081080 debug      [Thruway\Transport\RatchetTransportProvider 22] RatchetTransportProvider::onOpen
php_1            | [router 0 21] 2016-10-24T12:10:35.0086120 info       [Thruway\Peer\Router 22] New Session started {"type":"ratchet","transportAddress":"172.18.0.5"}
php_1            | [router 0 21] 2016-10-24T12:10:35.0149500 debug      [Thruway\Transport\RatchetTransportProvider 22] onMessage: ([1,"sales",{"roles":{"caller":{"features":{"caller_identification":true,"progressive_call_results":true}},"callee":{"features":{"caller_identification":true,"pattern_based_registration":true,"shared_registration":true,"progressive_call_results":true,"registration_revocation":true}},"publisher":{"features":{"publisher_identification":true,"subscriber_blackwhite_listing":true,"publisher_exclusion":true}},"subscriber":{"features":{"publisher_identification":true,"pattern_based_subscription":true,"subscription_revocation":true}}},"authmethods":["wampcra"],"authid":"eyJ0eXAiOiJKV1QiLCJhbG21ciOiJIUzI1NiJ9.eyJpZCI6Ijk1YTgwN123zhjLTI1ZjEtNGYxOC05YjA1LTMwZGM1YWY5NjlkZSIsImVtYWlsIjoiYWRtaW5AZXhhbXBsZS5jb20iLCJyb2xlIjoiYWRtaW4iLCJuYW1lIjoiUmVuYXRlIiwiZmFjZWJvb2tJZCI6bnVsbCwiZ29vZ2xlSWQiOm51bGwsImxpbmtlZGluSWQiOm51bGwsImFjdGl2ZSI6dHJ1ZSwic3ViIjoidXNlciIsImV4cCI6MTQ3NzM5NzEyMX0.tPWtuPCzXlLBVGRPlI_vq9RUkjp00giwOOs4bGvxgg1"}])
php_1            | [router 0 21] 2016-10-24T12:10:35.0155000 debug      [Thruway\Realm 22] Got Hello
php_1            | [router 0 21] 2016-10-24T12:10:35.0173820 debug      [Thruway\Authentication\WampCraAuthProvider 22] Client onMessage: [Thruway\Message\InvocationMessage]
php_1            | [router 0 21] 2016-10-24T12:10:35.0200560 debug      [Thruway\Authentication\AuthenticationManager 22] Client onMessage: [Thruway\Message\ResultMessage]
php_1            | [router 0 21] 2016-10-24T12:10:35.0951650 debug      [Thruway\Transport\RatchetTransportProvider 22] onMessage: ([5,"JsqDL9nUHfpFsRJOy9cQy6uXP8PWeDUeExoHI9nJkW8=",{}])
php_1            | [router 0 21] 2016-10-24T12:10:35.0962210 debug      [Thruway\Authentication\WampCraAuthProvider 22] Client onMessage: [Thruway\Message\InvocationMessage]
php_1            | [router 0 21] 2016-10-24T12:10:35.0968600 debug      [Thruway\Authentication\AuthenticationManager 22] Client onMessage: [Thruway\Message\ResultMessage]
php_1            | [router 0 21] 2016-10-24T12:10:35.0974710 debug      [Thruway\Role\Broker 22] Broker onMessage for {"type":"dummyTransport","transportAddress":"dummy"}: [16,5800741427391633,{},"wamp.metaevent.session.on_join",[{"realm":"sales","authprovider":null,"authid":"eyJ0eXAiOiJKV1QiLCJhbG21ciOiJIUzI1NiJ9.eyJpZCI6Ijk1YTgwN123zhjLTI1ZjEtNGYxOC05YjA1LTMwZGM1YWY5NjlkZSIsImVtYWlsIjoiYWRtaW5AZXhhbXBsZS5jb20iLCJyb2xlIjoiYWRtaW4iLCJuYW1lIjoiUmVuYXRlIiwiZmFjZWJvb2tJZCI6bnVsbCwiZ29vZ2xlSWQiOm51bGwsImxpbmtlZGluSWQiOm51bGwsImFjdGl2ZSI6dHJ1ZSwic3ViIjoidXNlciIsImV4cCI6MTQ3NzM5NzEyMX0.tPWtuPCzXlLBVGRPlI_vq9RUkjp00giwOOs4bGvxgg1","authrole":"user","authroles":["user","authenticated_user"],"authmethod":"wampcra","session":5419777708509425,"role_features":{"caller":{"features":{"caller_identification":true,"progressive_call_results":true}},"callee":{"features":{"caller_identification":true,"pattern_based_registration":true,"shared_registration":true,"progressive_call_results":true,"registration_revocation":true}},"publisher":{"features":{"publisher_identification":true,"subscriber_blackwhite_listing":true,"publisher_exclusion":true}},"subscriber":{"features":{"publisher_identification":true,"pattern_based_subscription":true,"subscription_revocation":true}}}}]]

After this subscription doesn't exists.

Is there a way to avoid this without resubscribe? For example, send some pings from server to client.

davidwdan commented 7 years ago

You can create a ping by creating a topic that you publish to periodically.

NewOldMax commented 7 years ago

I think it's little dirty, not?

davidwdan commented 7 years ago

Yes it is. The next version of Ratchet will support ping/pong, so this is just a temporary solution.

https://github.com/ratchetphp/Ratchet/pull/401

valepu commented 7 years ago

I'm having this same issue. I launch the server from comand line and if i don't publish anything for some time (about 20-30 minutes) i get what looks like a log of all the previous calls on the console and the server just hangs (the process is active, but it doesn't accept connections anymore). Following this suggestion i have made a topic where i publish every 5 minutes. Now it lasts some hours (about 6-7) but then the same thing happens eventually.

Is it possible to know what is causing the issue? I don't think a "keep alive" mechanism should be needed at all in the first place

I am working on a windows 10 machine using PHP 5.6 and dev-master version of the bundle (but it happened even with the latest release)

davidwdan commented 6 years ago

Fixed in v0.3.0