change keep alive from const to variable
added function for waiting ping response