Skip to content

Commit cb6604d

Browse files
committed
auto-reconnect mechinism
1 parent 7b35598 commit cb6604d

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/main/java/com/cisco/trex/stateless/TRexTransport.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,21 @@ public synchronized String sendJson(String json) {
142142
}
143143
byte[] msg = zmqSocket.recv();
144144

145+
if (msg == null) {
146+
zmqSocket.connect(this.connectionString);
147+
try {
148+
zmqSocket.send(compressed);
149+
} catch (ZMQException e) {
150+
throw new IllegalStateException(
151+
"Did not get any response from server "
152+
+ getHost()
153+
+ " within timeout "
154+
+ zmqSocket.getReceiveTimeOut(),
155+
e);
156+
}
157+
msg = zmqSocket.recv();
158+
}
159+
145160
String response = this.dataCompressor.decompressBytesToString(msg);
146161
LOGGER.debug("JSON Resp: {}", response);
147162
return response;

0 commit comments

Comments
 (0)