The documentation is not clear on how long a subscription is good for. I have found references (forums posts) that say 2 hours but unable to find a documented source within SF docs. However, this part has me a bit perplexed (all quotes from docs):
The client receives events from the server while it maintains a long-lived connection.
- If no events are generated and the client is waiting and the server closes the connection, after two minutes the client should reconnect immediately.
Socket timeout: 110 seconds
A client receives events (JSON-formatted HTTP responses) while it waits on a connection. If no events are generated and the client is still waiting, the connection times out after 110 seconds and the server closes the connection. Clients should reconnect before two minutes to avoid the connection timeout.
The docs on the protocol state
Long polling, also called Comet programming, allows emulation of an information push from a server to a client. Similar to a normal poll, the client connects and requests information from the server. However, instead of sending an empty response if information isn't available, the server holds the request and waits until information is available (an event occurs). The server then sends a complete response to the client. The client then immediately re-requests information. The client continually maintains a connection to the server, so it’s always waiting to receive a response. In the case of server timeouts, the client connects again and starts over.
I had a Lightning component open and subscribed. Waited 90 seconds and sent the API request to update the subscribed record. The message was received. Waited 60 more seconds and updated again and the message was received. So at least in this minimal test neither of the above appears to be true. I think I am misreading it or something....
I guess I may be missing some terminology assumptions or related information that provides clarity.
Q: Once you establish a connection and subscribe to the push topic, do you have to resubscribe/connect every 110 seconds if no events are received or not...
Bonus If the answer is yes to the above, how would you do this in Lightning. Would using a set timeout for close to two minutes be the correct way