fix timeout and socket ssl wrapping