You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If server and client are connected and the server changes its ip address (seems to happen in AWS kubernetes quite often), than the client still thinks its connected but does not receive events anymore posted to the server. The connection seems lost. Only restarting the client gets it back to work.
For now, I build a docker image statrting the client with the following script and use it in kubernetes:
const program = require('commander')
const SmeeClient = require('smee-client')
program
.version("0.0.1", '-v, --version')
.usage('[options]')
.option('-u, --url <url>', 'URL of the webhook proxy service. Default: https://smee.io/new')
.option('-t, --target <target>', 'Full URL (including protocol and path) of the target service the events will forwarded to. Default: http://127.0.0.1:PORT/PATH')
.parse(process.argv)
if(!program.url) {
console.error("No url set. Use '-u' as argument.");
return;
}
if(!program.target) {
console.error("No target set. Use '-t' as argument.");
return;
}
const smee = new SmeeClient({
source: program.url,
target: program.target,
logger: console
})
const maxPingDifferenceAllowedInSeconds = 60;
const checkIntervallInSeconds = 15;
let lastPing = Date.now();
const events = smee.start()
events.addEventListener('ping', function(){
console.log("received ping");
lastPing = Date.now();
});
const pingDiffIntervalId = setInterval( function(){
const pingDiff = Date.now() - lastPing;
console.log("pingDiff: "+pingDiff);
if((pingDiff / 1000) >= maxPingDifferenceAllowedInSeconds) {
// Stop forwarding events
console.error("Ping difference of server higher than allowed (pingDiff in ms: "+pingDiff+", maxPingDifferenceAllowedInSeconds"+maxPingDifferenceAllowedInSeconds+")");
events.close()
clearInterval(pingDiffIntervalId);
}
}, checkIntervallInSeconds * 1000);
This script frequently checks if the client is still receiving the ping event, which it doesnt when the server changes the ip. If it is not received for about 60s the the client will exit. This will cause kubernetes to restart the client (pod) and thus gets the connection working again.
I think this should somehow be handled by default.
The text was updated successfully, but these errors were encountered:
@benzman81 Thanks for the code showing how you got it working! Yeh, the smee server sends a keep alive signal every 30 seconds, which is intended to help with keeping the browser connected. I think your solution is basically what we need to do, and maybe add an option to enable a keep-alive interval since that may be something a user would want to customize? We could add the listener/handler in the start() method
Would you be willing to put together a PR with your code? Happy to review it and cut a release integrating this feature.
If server and client are connected and the server changes its ip address (seems to happen in AWS kubernetes quite often), than the client still thinks its connected but does not receive events anymore posted to the server. The connection seems lost. Only restarting the client gets it back to work.
For now, I build a docker image statrting the client with the following script and use it in kubernetes:
This script frequently checks if the client is still receiving the ping event, which it doesnt when the server changes the ip. If it is not received for about 60s the the client will exit. This will cause kubernetes to restart the client (pod) and thus gets the connection working again.
I think this should somehow be handled by default.
The text was updated successfully, but these errors were encountered: