There is such a Webstore connection, I use the library:
import com.neovisionaries.ws.client.*; Long PING = 40000L; Long PONG = 40000L WebSocketFactory wsf = new WebSocketFactory(); Main.ws = wsf .createSocket(host) .addProtocol(protocol) .setUserInfo(username, password) .setPingInterval(PING) .setPongInterval(PONG) .connect() ; The socket works normally for about 60 minutes (a couple of days was exactly 60 minutes, today the time has increased slightly (about 70 minutes)), and then hangs (break). On the server side, they tell me that this is on my side or there may be a problem with the network (based on the exit code on the server)
I have already tried to send a ping every 40 seconds on my own, and I discovered this hangup so it turns out - ping is sent, and the answer is NO, respectively. here in this place it just hangs.
..... if(Main.ws.isOpen()) { LOGGER.info("WS-PING sendState"); Main.ws.sendPing(); // зависает здесь } ...... How to overcome it?
As an option, I thought to make reconnect - but it hangs. Although there is another option that the problem may be related to threads, since this socket is not yet synchronized with the main thread and ends later than the main Main.