<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<!--[if !mso]><style>v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]--><style><!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
        {mso-style-priority:99;
        mso-style-link:"Balloon Text Char";
        margin:0cm;
        margin-bottom:.0001pt;
        font-size:8.0pt;
        font-family:"Tahoma","sans-serif";}
span.BalloonTextChar
        {mso-style-name:"Balloon Text Char";
        mso-style-priority:99;
        mso-style-link:"Balloon Text";
        font-family:"Tahoma","sans-serif";}
span.EmailStyle19
        {mso-style-type:personal;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
span.apple-converted-space
        {mso-style-name:apple-converted-space;}
span.EmailStyle21
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="color:#1F497D">Hi all,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">I wrote an Erlang ssh client module for running commands on a remote host over an ssh connection.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">The main calls to Erlang ssh library functions to setup the connection are the following:<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:36.0pt"><span style="font-family:"Courier New";color:black">ssh:connect/4<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:36.0pt"><span style="font-family:"Courier New";color:black">ssh_connection:session_channel/2<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:36.0pt"><span style="font-family:"Courier New";color:black">ssh_connection:ptty_alloc/3<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:36.0pt"><span style="font-family:"Courier New";color:black">ssh_connection:shell/2<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">afterwards I’m issuing a command to remote host via:<o:p></o:p></span></p>
<p class="MsoNormal" style="text-indent:36.0pt"><span style="font-family:"Courier New";color:black">ssh_connection:send/3<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">and receiving related reply in a msg loop, with the following format:<o:p></o:p></span></p>
<p class="MsoNormal" style="text-indent:36.0pt"><span style="font-family:"Courier New";color:black">{ssh_cm, ConnectionRef, {data, ChannelId, Type, Data}}</span><span style="font-family:"Courier New";color:#1F497D"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">Everything works fine and I’m able to issue commands and receive responses correctly.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">What I’m experiencing is a strange behavior on long lasting ssh sessions: when I start a long loop of
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">ssh send-receive requests, it seems like the client connection hangs after a certain number or positive command requests (several thousands),<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">waiting indefinitely for a reply, wherefrom it exits with timeout.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">The only way to recover from this status is to disconnect and reconnect to the server.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">I tried with both Erlang OTP/17.x and OTP/18.x and towards remote hosts running Linux and/or  Solaris OS, but the result is the same.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">This behavior seems to be deterministic: given a command, it happens after the same number of issued requests (e.g. for a trivial “pwd” command,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">the client always hangs after 2510 tries!!).<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">This make me think as there’s a limited receive buffer size somewhere into the client ssh library or something similar (maybe something that I should set at connection setup?);
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">since I’m quite newbie to Erlang, I’d very much appreciate if anyone could help me to find out the reason for this behaviour.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">Thanks in advance for your help!<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">Regards,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">/Mario<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal" style="margin-bottom:12.0pt"><a href="http://www.ericsson.com/" target="_blank"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";text-decoration:none"><img border="0" width="68" height="60" id="_x0000_i1026" src="cid:image003.gif@01D2548C.96EA2E50" alt="Ericsson"></span></a><span style="font-size:10.0pt;font-family:"Arial","sans-serif";color:#1F497D"><br>
<br>
</span><span style="color:#1F497D"><o:p></o:p></span></p>
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Arial","sans-serif";color:#333333">MARIO SANTORO
</span></b><span style="font-size:10.0pt;font-family:"Arial","sans-serif";color:#333333"><br>
Service Project Manager <br>
Region Mediterranean <br>
RMED ITC CU SCM SL AIB DMO</span><span style="color:#333333"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#333333"><br>
</span><b><span style="font-size:10.0pt;font-family:"Arial","sans-serif";color:#333333">Ericsson</span></b><span style="font-size:10.0pt;font-family:"Arial","sans-serif";color:#333333"><br>
Via Anagnina, 203<br>
00118, ROME, ITALY<br>
Mobile +39 335 699 5215<br>
Office +39 06 7258 8404<br>
mario.santoro@ericsson.com<br>
www.ericsson.com </span><span style="color:#333333"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Arial","sans-serif";color:#1F497D"><br>
<br>
</span><a href="http://www.ericsson.com/current_campaign" target="_blank"><span style="font-size:9.0pt;font-family:"Arial","sans-serif";text-decoration:none"><img border="0" width="500" height="80" id="_x0000_i1025" src="cid:image004.gif@01D2548C.96EA2E50" alt="http://www.ericsson.com/current_campaign"></span></a><span style="color:#1F497D"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="IT" style="font-size:8.0pt;font-family:"Arial","sans-serif";color:#333333">----------<br>
<br>
Legal entity: Ericsson Telecomunicazioni SpA, registered office in Rome. </span><span style="font-size:8.0pt;font-family:"Arial","sans-serif";color:#333333">This Communication is Confidential. We only send and receive email on the basis of the terms set out
 at <a href="http://www.ericsson.com/email_disclaimer" title="http://www.ericsson.com/email_disclaimer">
www.ericsson.com/email_disclaimer</a> </span><span style="color:#1F497D"><o:p></o:p></span></p>
</div>
</body>
</html>