7070DEFAULT_SESSION_RENEWAL_OFFSET = 120 # seconds
7171DEFAULT_BLOCK_TIME = 2 # seconds
7272
73+ GRPC_CHANNEL_OPTIONS = [
74+ ("grpc.keepalive_time_ms" , 45000 ),
75+ ("grpc.keepalive_timeout_ms" , 5000 ),
76+ ("grpc.http2.max_pings_without_data" , 5 ),
77+ ("grpc.keepalive_permit_without_calls" , 1 ),
78+ ]
79+
7380
7481class AsyncClient :
7582 def __init__ (
@@ -88,9 +95,16 @@ def __init__(
8895
8996 # chain stubs
9097 self .chain_channel = (
91- grpc .aio .secure_channel (network .grpc_endpoint , credentials )
98+ grpc .aio .secure_channel (
99+ target = network .grpc_endpoint ,
100+ credentials = credentials ,
101+ options = GRPC_CHANNEL_OPTIONS ,
102+ )
92103 if (network .use_secure_connection and credentials is not None )
93- else grpc .aio .insecure_channel (network .grpc_endpoint )
104+ else grpc .aio .insecure_channel (
105+ target = network .grpc_endpoint ,
106+ options = GRPC_CHANNEL_OPTIONS ,
107+ )
94108 )
95109
96110 self .stubCosmosTendermint = tendermint_query_grpc .ServiceStub (
@@ -106,9 +120,16 @@ def __init__(
106120
107121 # exchange stubs
108122 self .exchange_channel = (
109- grpc .aio .secure_channel (network .grpc_exchange_endpoint , credentials )
123+ grpc .aio .secure_channel (
124+ target = network .grpc_exchange_endpoint ,
125+ credentials = credentials ,
126+ options = GRPC_CHANNEL_OPTIONS ,
127+ )
110128 if (network .use_secure_connection and credentials is not None )
111- else grpc .aio .insecure_channel (network .grpc_exchange_endpoint )
129+ else grpc .aio .insecure_channel (
130+ target = network .grpc_exchange_endpoint ,
131+ options = GRPC_CHANNEL_OPTIONS ,
132+ )
112133 )
113134 self .stubMeta = exchange_meta_rpc_grpc .InjectiveMetaRPCStub (
114135 self .exchange_channel
@@ -137,9 +158,16 @@ def __init__(
137158
138159 # explorer stubs
139160 self .explorer_channel = (
140- grpc .aio .secure_channel (network .grpc_explorer_endpoint , credentials )
161+ grpc .aio .secure_channel (
162+ target = network .grpc_explorer_endpoint ,
163+ credentials = credentials ,
164+ options = GRPC_CHANNEL_OPTIONS ,
165+ )
141166 if (network .use_secure_connection and credentials is not None )
142- else grpc .aio .insecure_channel (network .grpc_explorer_endpoint )
167+ else grpc .aio .insecure_channel (
168+ target = network .grpc_explorer_endpoint ,
169+ options = GRPC_CHANNEL_OPTIONS ,
170+ )
143171 )
144172 self .stubExplorer = explorer_rpc_grpc .InjectiveExplorerRPCStub (
145173 self .explorer_channel
0 commit comments