Skip to content

Commit 387cee7

Browse files
authored
Revert "auto-reconnect mechinism"
1 parent 5866306 commit 387cee7

File tree

1 file changed

+6
-22
lines changed

1 file changed

+6
-22
lines changed

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

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
import org.zeromq.SocketType;
1414
import org.zeromq.ZMQ;
1515
import org.zeromq.ZMQException;
16-
import zmq.ZError;
1716

1817
/** TRex Transport class to create zmq socket for connection to trex server */
1918
public class TRexTransport {
@@ -134,32 +133,17 @@ public synchronized String sendJson(String json) {
134133
try {
135134
zmqSocket.send(compressed);
136135
} catch (ZMQException e) {
137-
throwTimeoutException(e);
136+
throw new IllegalStateException(
137+
"Did not get any response from server "
138+
+ getHost()
139+
+ " within timeout "
140+
+ zmqSocket.getReceiveTimeOut(),
141+
e);
138142
}
139143
byte[] msg = zmqSocket.recv();
140-
// add this if-block to deal with the connect lost error which is caused
141-
// after a long time the client-server don't interactive
142-
if (msg == null && zmqSocket.errno() == ZError.ENOTCONN) {
143-
zmqSocket.connect(this.connectionString);
144-
try {
145-
zmqSocket.send(compressed);
146-
} catch (ZMQException e) {
147-
throwTimeoutException(e);
148-
}
149-
msg = zmqSocket.recv();
150-
}
151144

152145
String response = this.dataCompressor.decompressBytesToString(msg);
153146
LOGGER.debug("JSON Resp: {}", response);
154147
return response;
155148
}
156-
157-
private void throwTimeoutException(Exception e) {
158-
throw new IllegalStateException(
159-
"Did not get any response from server "
160-
+ getHost()
161-
+ " within timeout "
162-
+ zmqSocket.getReceiveTimeOut(),
163-
e);
164-
}
165149
}

0 commit comments

Comments
 (0)