token regeneration and socket fix