background thread connection handler