Add socket timeout and NN handling