Closed Slavix72 closed 4 years ago
What is happening here is;
when the naz
command line app starts, we shedule about 4 different coroutines in the python eventloop;
https://github.com/komuw/naz/blob/cc6ce6472f9622e7c317fb4309cbf66bf60d15e1/cli/cli.py#L107-L112
Of note, is the connect()
and tranceiver_bind()
coroutines. Since those coroutines are scheduled to run concurrently, it so happens that the tranceiver_bind()
coroutine can run before the connect()
coroutine has finished.
If that happens, tranceiver_bind()
will fail. If it fails, then naz
needs to schedule another attempt to bind to the SMSC. Since the previous bind had failed, it makes sense to wait for a while before issuing another bind request.
How long does naz
wait before sending another bind request? currently naz
waits for a duration equal to naz.Client.socket_timeout
. By default socket_timeout
is 30seconds. ;
https://github.com/komuw/naz/blob/cc6ce6472f9622e7c317fb4309cbf66bf60d15e1/naz/client.py#L1803-L1816
When issuing the bind request, naz
also does a tcp connection because the previous bind may have failed because of tcp failure.
So, it would be good to have tranceiver_bind()
coroutine wait for the connect()
coroutine to finish first before running. But the implementation to do that would be overkill and I do not think the effort is worth the gain
How long does naz wait before sending another bind request? currently naz waits for a duration equal to naz.Client.socket_timeout. By default socket_timeout is 30seconds.
Do note that this is an implementation detail and is likely to change. ie, users should not rely on this behaviour.
The first (simplest, but not beautiful) step is remove client.connect() and client.tranceiver_bind() tasks = asyncio.gather(
#client.tranceiver_bind(),
client.dequeue_messages(),
client.receive_data(),
client.enquire_link()
) re_establish_conn_bind() can perform tcp-connection and bind_transciever......
I do not consider this to be a major problem that needs to be solved. It is an annoyance, but an annoyance that I'm happy to live with.
Unless it turns out that there is a serious bug hiding somewhere underneath, I'm going to close this issue.
Python 3.7 Naz 0.7.4 socket_timeout = 30.0
Client performs connection to smsc... Are packets 1 and 4 establish 2 tcp-sessions? And bind_transceiver is sent across second session on 30 seconds after starting...