How can I keep the socket stable

My program will connect the marker (wss://md.tradovateapi.com/v1/websocket) and demo trade (wss://demo.tradovateapi.com/v1/websocket), live trade ( wss://live.tradovateapi.com/v1/websocket) in same time,
and I buy 2 market data (double fee). and I deploy the program on the server in Virginia zone so that delay to market is 20ms.the ping delay is less than 1ms.the server network is good.

but I found the socket will be broken,I write the reconnect logic,but it to frequency recently. But I found the Tr UI client is good to connect, I want know what reason may be make broke socket,and how Can I keep the socket stable.

my socket will receive websocket onclose : code:1000 reason:Bye

2022-07-06 23:58:53.695 [][OkHttp https://demo.tradovateapi.com/...] INFO  c.a.q.f.c.TradoSocketListener DemoTrade onClosing code:1000 reason:Bye 等待异常后重连
2022-07-06 23:58:53.703 [][OkHttp https://live.tradovateapi.com/...] INFO  c.a.q.f.c.TradoSocketListener LiveTrade onClosing code:1000 reason:Bye 等待异常后重连
2022-07-06 23:58:53.707 [][OkHttp https://md.tradovateapi.com/...] INFO  c.a.q.f.c.TradoSocketListener Market onClosing code:1000 reason:Bye 等待异常后重连

and socket is bad when write data:

2022-07-06 23:59:06.172 [][OkHttp WebSocket https://demo.tradovateapi.com/...] ERROR c.a.q.f.c.TradoSocketListener DemoTrade 链接异常: 0秒后重连 error:
java.net.SocketException: Broken pipe (Write failed)
	at java.net.SocketOutputStream.socketWrite0(Native Method) ~[?:1.8.0_292]
	at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:111) ~[?:1.8.0_292]
	at java.net.SocketOutputStream.write(SocketOutputStream.java:155) ~[?:1.8.0_292]
	at sun.security.ssl.SSLSocketOutputRecord.deliver(SSLSocketOutputRecord.java:319) ~[?:1.8.0_292]
	at sun.security.ssl.SSLSocketImpl$AppOutputStream.write(SSLSocketImpl.java:1179) ~[?:1.8.0_292]
	at okio.Okio$1.write(Okio.java:79) ~[okio-1.17.2.jar!/:?]
	at okio.AsyncTimeout$1.write(AsyncTimeout.java:180) ~[okio-1.17.2.jar!/:?]
	at okio.RealBufferedSink.emit(RealBufferedSink.java:186) ~[okio-1.17.2.jar!/:?]

and I will try reconnect,first I will close this bad socket

2022-07-06 23:59:06.173 [][OkHttp WebSocket https://md.tradovateapi.com/...] INFO  c.a.q.f.c.TradoSocket Market will close

and reconnect socket,tree socket is reconnect ok,will get this log,same with demo,live,market.

2022-07-06 23:59:07.175 [618b1616339950179769a2d50382c843][scheduling-1] INFO  c.a.q.f.c.TradoSocket DemoTrade reconnect
2022-07-06 23:59:07.175 [618b1616339950179769a2d50382c843][scheduling-1] INFO  c.a.q.f.c.TradoSocket DemoTrade[demo] socket begin connect
2022-07-06 23:59:07.175 [618b1616339950179769a2d50382c843][scheduling-1] INFO  c.a.q.f.c.TradoSocket DemoTrade[demo] socket connect ok

2022-07-06 23:59:07.239 [][OkHttp https://demo.tradovateapi.com/...] INFO  c.a.q.f.c.TradoSocketListener DemoTrade socket open
2022-07-06 23:59:07.239 [][OkHttp https://demo.tradovateapi.com/...] INFO  c.a.q.f.c.TradoSocketListener DemoTrade session opening
2022-07-06 23:59:07.268 [][OkHttp https://demo.tradovateapi.com/...] INFO  c.a.q.f.c.TradoSocketListener DemoTrade socket session build!
2022-07-06 23:59:07.350 [618b1616339950179769a2d50382c843][scheduling-1] INFO  c.a.q.f.t.TradeService DemoTrade synchronize!

and also some time get this error when try to reconnect:

2022-07-06 15:01:03.679 [][OkHttp https://demo.tradovateapi.com/...] ERROR c.a.q.f.c.TradoSocketListener DemoTrade 链接异常: 0秒后重连 error:
javax.net.ssl.SSLException: Connection reset
	at sun.security.ssl.Alert.createSSLException(Alert.java:127) ~[?:1.8.0_292]
	at sun.security.ssl.TransportContext.fatal(TransportContext.java:324) ~[?:1.8.0_292]
	at sun.security.ssl.TransportContext.fatal(TransportContext.java:267) ~[?:1.8.0_292]
	at sun.security.ssl.TransportContext.fatal(TransportContext.java:262) ~[?:1.8.0_292]
	at sun.security.ssl.SSLSocketImpl.handleException(SSLSocketImpl.java:1554) ~[?:1.8.0_292]
	at sun.security.ssl.SSLSocketImpl.access$400(SSLSocketImpl.java:73) ~[?:1.8.0_292]
	at sun.security.ssl.SSLSocketImpl$AppInputStream.read(SSLSocketImpl.java:964) ~[?:1.8.0_292]
	at okio.Okio$2.read(Okio.java:140) ~[okio-1.17.2.jar!/:?]
	at okio.AsyncTimeout$2.read(AsyncTimeout.java:237) ~[okio-1.17.2.jar!/:?]
	at okio.RealBufferedSource.request(RealBufferedSource.java:72) ~[okio-1.17.2.jar!/:?]
	at okio.RealBufferedSource.require(RealBufferedSource.java:65) ~[okio-1.17.2.jar!/:?]

Is that socket close by TR server is normal?
and can I reconnect right now when I received the close msg?like code 1000 reason: Bye
or I need wait some second and reconnect?