|
20 | 20 | import ssl
|
21 | 21 | import sys
|
22 | 22 | import time
|
| 23 | +from secrets import token_hex |
23 | 24 | from dataclasses import dataclass
|
24 | 25 | from email.parser import BytesParser
|
25 | 26 | from random import shuffle
|
|
56 | 57 | Subscription,
|
57 | 58 | )
|
58 | 59 |
|
59 |
| -__version__ = '2.1.6' |
| 60 | +__version__ = '2.1.7' |
60 | 61 | __lang__ = 'python3'
|
61 | 62 | _logger = logging.getLogger(__name__)
|
62 | 63 | PROTOCOL = 1
|
@@ -168,12 +169,8 @@ def __init__(self) -> None:
|
168 | 169 | self._reconnection_task: Union[asyncio.Task[None], None] = None
|
169 | 170 | self._reconnection_task_future: Optional[asyncio.Future] = None
|
170 | 171 | self._max_payload: int = DEFAULT_MAX_PAYLOAD_SIZE
|
171 |
| - # This is the client id that the NATS server knows |
172 |
| - # about. Useful in debugging application errors |
173 |
| - # when logged with this identifier along |
174 |
| - # with nats server log. |
175 |
| - # This would make more sense if we log the server |
176 |
| - # connected to as well in case of cluster setup. |
| 172 | + |
| 173 | + # client id that the NATS server knows about. |
177 | 174 | self._client_id: Optional[str] = None
|
178 | 175 | self._sid: int = 0
|
179 | 176 | self._subs: Dict[int, Subscription] = {}
|
@@ -929,8 +926,10 @@ async def _request_new_style(
|
929 | 926 | await self._init_request_sub()
|
930 | 927 | assert self._resp_sub_prefix
|
931 | 928 |
|
932 |
| - # Use a new NUID for the token inbox and then use the future. |
| 929 | + # Use a new NUID + couple of unique token bytes to identify the request, |
| 930 | + # then use the future to get the response. |
933 | 931 | token = self._nuid.next()
|
| 932 | + token.extend(token_hex(2).encode()) |
934 | 933 | inbox = self._resp_sub_prefix[:]
|
935 | 934 | inbox.extend(token)
|
936 | 935 | future: asyncio.Future = asyncio.Future()
|
|
0 commit comments