I can't explain the hang but what you're seeing is normal for the ls command. The ls command opens and closes a bunch of shorter lived connections. The NSH proxy will only keep a connection open until the client-side has called close on that connection so if you see a connection getting closed on the proxy it's because the client told it to (usually).
For example, you'll notice if you turn on debug logging on an agent and do something simple like:
and then look at the log entries, you'll see that the ls command opened up at least two new connections to the agent to process the ls. Depending on what's in the directory, you could get more connections as well (and also depending on the ls flags you passed in).
Since a single NSH command can be used against 100s/1000s of servers in one call, we don't keep the connections open any longer then we need to otherwise you'll run out of file descriptors.
Ok, that makes sense about why there are multiple connections. But is it possible they aren't staying opened long enough? Is there a variable in the app server settings that might be dictacting this?