Fix NPE which accoured when connection was refused