I am having problems using erlang ssh against an OpenSSH server. I am establishing an ssh connection and then in a freshly spawned process I will do this...<div><br></div><div><br></div><div>command(Conn, Cmd) -></div>
<div> {ok,Chan} = ssh_connection:session_channel(Conn, infinity),</div><div> success = ssh_connection:exec(Conn, Chan, Cmd, infinity),</div><div> ... receive data messages until eof...</div><div> ssh_connection:close(Conn, Chan),</div>
<div> ok.</div><div><br></div><div><br></div><div><br></div><div>I run about 6 of these commands sequentially (new process for each), and most of the time OpenSSH gets angry with me and drops the whole connection. The error given is...</div>
<div><br></div><div><barrage of debug messages talking about shutting down channel 1></div><div>channel_by_id: 1: bad id: channel free</div><div>Disconnecting: Received oclose for nonexistent channel 1.</div><div><br>
</div><div><br></div><div><br></div><div>But.... if I add a delay before the close() everything seems to work perfectly:</div><div><br></div><div><div>command(Conn, Cmd) -></div><div> {ok,Chan} = ssh_connection:session_channel(Conn, infinity),</div>
<div> success = ssh_connection:exec(Conn, Chan, Cmd, infinity),</div><div> ... receive data messages until eof...</div><div> timer:delay(1000),</div><div> ssh_connection:close(Conn, Chan),</div><div> ok.</div><br class="Apple-interchange-newline">
</div><div><br></div><div>Dan.</div>