The channel number on the putty side is 0x100, and on the Erlang side it is 0x0.  Erlang is responding to <span style="white-space:pre-wrap">SSH_MSG_CHANNEL_REQUEST using 0x0, however RFC4254 says the responses should be...</span><br>
<br><pre style="word-wrap:break-word;white-space:pre-wrap"><br class="Apple-interchange-newline">
      byte      SSH_MSG_CHANNEL_SUCCESS
      uint32    recipient channel


      byte      SSH_MSG_CHANNEL_FAILURE
      uint32    recipient channel
</pre><br class="Apple-interchange-newline"><br>...and I interpret "recipient channel" as being the Putty side, which is 0x100.  Putty seems to cope when Erlang returns SUCCESS, but blows up when Erlang returns a FAILURE.<div>
<br></div><div>I could imagine this passing automated tests when both ends number their channels starting from 0.  I bet randomizing the channel numbers would reveal this and maybe other issues.</div><div><br></div><div>Dan.</div>
<div><br><br><br><div class="gmail_quote">On Tue, Apr 24, 2012 at 11:22 AM, Fyodor Ustinov <span dir="ltr"><<a href="mailto:ufm@ufm.su">ufm@ufm.su</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi!<br>
<br>
I added this patch - did not help.<br>
<br>
<a href="http://blog.ufm.su/putty.log" target="_blank">http://blog.ufm.su/putty.log</a> - this putty log.<div class="HOEnZb"><div class="h5"><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi!<br>
<br>
This might be a symptom of the "close race-condition"-bug  reported by Daniel. The patch for that bug is<br>
<br>
diff --git a/lib/ssh/src/ssh_channel.erl b/lib/ssh/src/ssh_channel.erl<br>
index 7b600ed..1938858 100644<br>
--- a/lib/ssh/src/ssh_channel.erl<br>
+++ b/lib/ssh/src/ssh_channel.erl<br>
@@ -1,7 +1,7 @@<br>
%%<br>
%% %CopyrightBegin%<br>
%%<br>
-%% Copyright Ericsson AB 2008-2011. All Rights Reserved.<br>
+%% Copyright Ericsson AB 2008-2012. All Rights Reserved.<br>
%%<br>
%% The contents of this file are subject to the Erlang Public License,<br>
%% Version 1.1, (the "License"); you may not use this file except in<br>
@@ -215,7 +215,7 @@ handle_info({ssh_cm, ConnectionManager, {closed, ChannelId}},<br>
                  close_sent = false} = State) -><br>
    %% To be on the safe side, i.e. the manager has already been terminated.<br>
    (catch ssh_connection:close(<u></u>ConnectionManager, ChannelId)),<br>
-    {stop, normal, State};<br>
+    {stop, normal, State#state{close_sent = true}};<br>
<br>
handle_info({ssh_cm, _, _} = Msg, #state{cm = ConnectionManager,<br>
                       channel_cb = Module,<br>
diff --git a/lib/ssh/src/ssh_connection_<u></u>manager.erl b/lib/ssh/src/ssh_connection_<u></u>manager.erl<br>
index e993f59..8c1f88e 100644<br>
--- a/lib/ssh/src/ssh_connection_<u></u>manager.erl<br>
+++ b/lib/ssh/src/ssh_connection_<u></u>manager.erl<br>
@@ -384,9 +384,10 @@ handle_call({close, ChannelId}, _,<br>
           #state{connection = Pid, connection_state =<br>
                  #connection{channel_cache = Cache}} = State) -><br>
    case ssh_channel:cache_lookup(<u></u>Cache, ChannelId) of<br>
-       #channel{remote_id = Id} -><br>
+       #channel{remote_id = Id} = Channel -><br>
           send_msg({connection_reply, Pid,<br>
                     ssh_connection:channel_close_<u></u>msg(Id)}),<br>
+           ssh_channel:cache_update(<u></u>Cache, Channel#channel{sent_close = true}),<br>
           {reply, ok, State};<br>
       undefined -><br>
           {reply, ok, State}<br>
<br>
<br>
Regards Ingela Erlang/OTP  team - Ericsson AB<br>
<br>
Daniel Goertzen wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Under Putty Session->Logging can you turn on "SSH Packets" and post the log showing the error?<br>
<br>
Dan.<br>
<br>
On Sun, Apr 22, 2012 at 3:58 AM, Fyodor Ustinov <<a href="mailto:ufm@ufm.su" target="_blank">ufm@ufm.su</a> <mailto:<a href="mailto:ufm@ufm.su" target="_blank">ufm@ufm.su</a>>> wrote:<br>
<br>
    Hi!<br>
<br>
    Windows ssh client PuTTY show message  "Disconnected: Received<br>
    SSH2_MSG_CHANNEL_FAILURE for nonexistent channel 0" while working<br>
    with erlang ssh daemon.<br>
<br>
    Erlang R15B01 (erts-5.9.1) [source] [64-bit] [smp:8:8]<br>
    [async-threads:0] [kernel-poll:false]<br>
<br>
    WBR,<br>
       Fyodor.<br>
<br>
    ______________________________<u></u>_________________<br>
    erlang-bugs mailing list<br>
    <a href="mailto:erlang-bugs@erlang.org" target="_blank">erlang-bugs@erlang.org</a> <mailto:<a href="mailto:erlang-bugs@erlang.org" target="_blank">erlang-bugs@erlang.org</a><u></u>><br>
    <a href="http://erlang.org/mailman/listinfo/erlang-bugs" target="_blank">http://erlang.org/mailman/<u></u>listinfo/erlang-bugs</a><br>
<br>
<br>
<br>
<br>
-- <br>
*Daniel Goertzen | Senior Software Engineer*<br>
Office: <a href="tel:828.610.4596" value="+18286104596" target="_blank">828.610.4596</a> | Fax: <a href="tel:828.322.5294" value="+18283225294" target="_blank">828.322.5294</a> | <a href="mailto:dang@networkintegritysystems.com" target="_blank">dang@networkintegritysystems.<u></u>com</a> <mailto:<a href="mailto:dang@networkintegritysystems.com" target="_blank">dang@<u></u>networkintegritysystems.com</a>><br>

*Network Integrity Systems | We Bring Security To Light™*<br>
<br>
1937 Tate Blvd. SE<br>
<br>
Hickory, North Carolina, USA 28602<br>
<br>
/Network Integrity Systems’ INTERCEPTOR™ Optical Network Security System is a Smart-PDS™ that ensures superior protection and cost effectiveness of classified networks.  For more information, visit our website at:<a href="http://www.networkintegritysystems.com" target="_blank">www.<u></u>networkintegritysystems.com</a> <<a href="http://www.networkintegritysystems.com/" target="_blank">http://www.<u></u>networkintegritysystems.com/</a>>.<u></u>/<br>

<br>
<br>
______________________________<u></u>____________<br>
INTERCEPTOR™ Optical Network Security System is made in the USA for the USA. Although not an export controlled item, because of the role it plays in the assurance of the safety and integrity of National Security Information, Network Integrity Systems (NIS) is committed to compliance with the U.S. Export Administration Act. Accordingly, NIS will not ship INTERCEPTOR products to certain foreign government end users without U.S. government approval and will refuse transactions with individuals or entities that have been denied export privileges.<br>

<br>
<br>
------------------------------<u></u>------------------------------<u></u>------------<br>
<br>
______________________________<u></u>_________________<br>
erlang-bugs mailing list<br>
<a href="mailto:erlang-bugs@erlang.org" target="_blank">erlang-bugs@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-bugs" target="_blank">http://erlang.org/mailman/<u></u>listinfo/erlang-bugs</a><br>
</blockquote>
<br>
</blockquote>
<br>
______________________________<u></u>_________________<br>
erlang-bugs mailing list<br>
<a href="mailto:erlang-bugs@erlang.org" target="_blank">erlang-bugs@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-bugs" target="_blank">http://erlang.org/mailman/<u></u>listinfo/erlang-bugs</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><span style="border-collapse:collapse"><b><font color="#000099" face="arial, helvetica, sans-serif">Daniel Goertzen | Senior Software Engineer</font></b></span><div>
<span style="border-collapse:collapse"><font face="arial, helvetica, sans-serif">Office: 828.610.4596 | Fax: 828.322.5294 | <a href="mailto:dang@networkintegritysystems.com" target="_blank">dang@networkintegritysystems.com</a><br>
<b><font color="#000099">Network Integrity Systems</font> | <font color="#ff0000">We Bring Security To Light™</font></b><font><div><p style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px">1937 Tate Blvd. SE<u></u><u></u></p>
</div>Hickory, North Carolina, USA 28602</font></font></span><div><span style="border-collapse:collapse"><font><span><br></span></font></span></div><div><span style="border-collapse:collapse"><font><p><i><span style="font-size:10.5pt;font-family:Calibri,sans-serif">Network Integrity Systems’ INTERCEPTOR™ Optical Network Security System is a Smart-PDS™ that ensures superior protection and cost effectiveness of classified networks.  For more information, visit our website at:<a href="http://www.networkintegritysystems.com/" style="color:rgb(17,85,204)" target="_blank">www.networkintegritysystems.com</a>.</span></i></p>
<div><p style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px"><span style="font-size:11pt;font-family:Arial,sans-serif;color:rgb(31,73,125)"><br>__________________________________________<br></span><span style="font-size:9pt;font-family:Arial,sans-serif;color:rgb(31,73,125)">INTERCEPTOR™ Optical Network Security System is made in the USA for the USA. Although not an export controlled item, because of the role it plays in the assurance of the safety and integrity of National Security Information, Network Integrity Systems (NIS) is committed to compliance with the U.S. Export Administration Act. Accordingly, NIS will not ship INTERCEPTOR products to certain foreign government end users without U.S. government approval and will refuse transactions with individuals or entities that have been denied export privileges.</span></p>
</div></font></span></div></div><br>
</div>