I have a question about the producer’s state when the network is weak.
- Does it transition from ‘connected’ to ‘disconnected,’ then attempt to reconnect and become ‘connected’ again with the same producer ID?
- Does it keep trying to reconnect indefinitely with the same producer ID until it fails?
- Additionally, how does the consumer’s state behave in response to the producer’s state?
Producer doesn’t have such state, the transport have and it changes states like this:
- Transport is connected
- Something happened with the network then the transport’s connection state changes to ‘disconnected’.
- Transport will try to connect back for few seconds I think it is around 8 seconds, and if network is back within that time then it’s connection state changes back to ‘connected’.
- Otherwise it’s connection state changes to ‘failed’
- After transport’s connection state changes to ‘failed’, it surrenders and it is up to you to get it back to life.
- You can use restart-ice mechanism to re-establish the connection so that it is back to it’s ‘connected’ states.
During all these stages mentioned above, the id of the transport remains unchanged. And so does the ids of the producers, consumers attached to that specific transport.
The answer to this is that the consumer’s state has no connection to the producer’s state. Event if producer’s transport is failed, the consumer’s transport will remain ‘connected’. They both are different entities and are established on different transports with the server.
Normally what we do is that whenever producer is closed, server is aware that producer is closed. On that event server closes it’s relevant consumers and that sends signal back to the consumers on client side based upon which you can do your cleaning but this is not something automatic you need to close the consumers on server manually to make it happen.
I see, I apologize for the confusion. What I meant was the producer’s transport and the consumer’s transport.
I wanted to inquire about a scenario: if user A (producing producer transport A) and user B consuming consumer transport A which is producer A, and user A changes their network, resulting in changes to the state of producer transport A (from ‘connected’ to ‘connecting’ and back to ‘connected,’ or even potential failure), will the state of consumer transport A for user B change based on the behavior of producer transport A?
No, as they both are on different transports(connection), the state of consumer will not change automatically based upon the state of the producer it is consuming.
These are the possible scenarios and outcomes:
If producer A’ transport is gone from ‘connected’ to ‘disconnected’ and comes back to ‘connected’ again then all good, no problem here. Producer is ok and consumer is ok as well.
If producer A is gone from ‘connected’ to ‘disconnected’ to ‘failed’ then you will do restart-ice mechanism for producer A’s transport and it should get back to ‘connected’ again, all good again, no problem here. Consumer will resume consuming producer A automatically, no need to do anything to consumer.
If producer A is gone from ‘connected’ to ‘disconnected’ to ‘failed’ and you don’t do restart-ice mechanism for producer A’s transport then it will remain in ‘failed’ state and it will have no impact on the consumer’s transport. Producer’s transport will be failed while consumer’s transport will be connected and healthy. The only difference will be that it will not consume anything until the producer A’s transport is back to normal.
I see, thank you for your explanation. It helps me a lot.