currently I am developing an webapp which will run on a tizen device (Samsung Gear S3). The purpose of that App is to send a message to a websocketserver (written in Python and running on my Computer) when swiping. When I swipe to the right I send a string1 and when I swipe left I send string2. The Problem is that it takes a while until the message arrives to the server (approx. 5 sec). This delay only happend when I run send the message the first time after a while. As far as I could observe that its 10 seconds. That means that I can send any message immidiataly within 10 seconds after the last. But when I Pause for more than 10 seconds there will be a delay of 5 sec.
So the qustion is whats the reason for that delay? Or how can I avoid this. It seems like there is a timeout, but How can I avoid this?
The code on client side (Tizen SmartWatch) is written in Javascript and jquery.
This is the clientsided Code I shorted a little. The HTML Part is not included.
<script>
var webSocketURL1 = "ws://";
var webSocketURL2 = "Computer10";
var webSocketURL3 = ":9998/echo";
function WS(String){
var webSocketURL=webSocketURL1+webSocketURL2+webSocketURL3;
var webSocket = new WebSocket(webSocketURL);
webSocket.onopen = function (e) {
console.log('connection open, readyState : ' + e.target.readyState);
webSocket.send(String);
};
function closeConnection() {
if (webSocket.readyState === 1) {
webSocket.close();
}
};
}
</script>
<script>
$(document).ready(function(){
$("body").on("swiperight",function(){
WS("string1");
});
});
</script>
<script>
$(document).ready(function(){
$("body").on("swipeleft",function(){
WS("string2");
});
});
</script>