<html 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=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:"Comic Sans MS";
        panose-1:3 15 7 2 3 3 2 2 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        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.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
        {mso-style-priority:34;
        margin-top:0in;
        margin-right:0in;
        margin-bottom:0in;
        margin-left:.5in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
p.msonormal0, li.msonormal0, div.msonormal0
        {mso-style-name:msonormal;
        mso-margin-top-alt:auto;
        margin-right:0in;
        mso-margin-bottom-alt:auto;
        margin-left:0in;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
span.EmailStyle18
        {mso-style-type:personal;
        font-family:"Courier New";}
span.EmailStyle19
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style>
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal">I’ve used this trick in the past to check if ports are available when bootstrapping MySQL instances in jobs that shared the same node:<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">    if (: < /dev/tcp/127.0.0.1/${MYSQL_PORT}) 2>/dev/null; then<o:p></o:p></p>
<p class="MsoNormal">        echo "MySQL port ${MYSQL_PORT} already taken."<o:p></o:p></p>
<p class="MsoNormal">        return 1<o:p></o:p></p>
<p class="MsoNormal">    fi<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">- Trey<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<div>
<p class="MsoNormal"><span style="font-size:10.5pt;color:black">-- <o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.5pt;color:black">Trey Dockendorf<o:p></o:p></span></p>
</div>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.5pt;color:black">HPC Systems Engineer<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><span style="font-size:10.5pt;color:black">Ohio Supercomputer Center</span><o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:12.0pt;color:black">From: </span></b><span style="font-size:12.0pt;color:black">OOD-users <ood-users-bounces+tdockendorf=osc.edu@lists.osc.edu> on behalf of Michael Coleman via OOD-users <ood-users@lists.osc.edu><br>
<b>Reply-To: </b>Michael Coleman <mcolema5@uoregon.edu>, User support mailing list for Open OnDemand <ood-users@lists.osc.edu><br>
<b>Date: </b>Friday, October 26, 2018 at 12:26 PM<br>
<b>To: </b>Jeremy Nicklas <jeremywnicklas@gmail.com>, User support mailing list for Open OnDemand <ood-users@lists.osc.edu>, "E.M. Dragowsky" <dragowsky@case.edu><br>
<b>Subject: </b>Re: [OOD-users] is nc/ncat an interactive app requirement?<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<p class="MsoNormal"><span style="font-family:"Courier New"">Looks like modern bash might be an alternative.  (You might also need the timeout command, which is also relatively modern.)</span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-family:"Courier New""> </span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">    https://stackoverflow.com/questions/4922943/test-from-shell-script-if-remote-tcp-port-is-open</span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-family:"Courier New""> </span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">Mike</span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-family:"Courier New""> </span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-family:"Courier New""> </span><o:p></o:p></p>
<p class="MsoNormal"><b>From:</b> OOD-users <ood-users-bounces@lists.osc.edu> <b>
On Behalf Of </b>Jeremy Nicklas via OOD-users<br>
<b>Sent:</b> Thursday, October 25, 2018 05:53 PM<br>
<b>To:</b> E.M. Dragowsky <dragowsky@case.edu>; User support mailing list for Open OnDemand <ood-users@lists.osc.edu><br>
<b>Subject:</b> Re: [OOD-users] is nc/ncat an interactive app requirement?<o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<div>
<p class="MsoNormal">Hi Em,<o:p></o:p></p>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">I think the members at OSC are pretty busy with a fairly large downtime currently, so I'll try to answer this. Good news is that it isn't due to a problem with your implementation of the interactive Jupyter app. Back when I wrote that portion
 of the code, I just forgot to document that netcat is a requirement for Interactive Apps to work out of the box (I made the incorrect assumption that it will exist in most standard installations). The relevant snippet of code where netcat is used can be seen
 here:<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><a href="https://github.com/OSC/ood_core/blob/a87f59ea9d24cdcbe505c9ab859bcb120bae9951/lib/ood_core/batch_connect/template.rb#L120-L126">https://github.com/OSC/ood_core/blob/a87f59ea9d24cdcbe505c9ab859bcb120bae9951/lib/ood_core/batch_connect/template.rb#L120-L126</a><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">In particular, netcat is used in a Bash function to determine if a port on the compute node is being used. This is used to not only find available ports for an interactive application server to listen on:<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><a href="https://github.com/OSC/bc_example_jupyter/blob/94d29b4ba705cfe3b17df8ce78f584a4a2f986c5/template/before.sh.erb#L32-L33">https://github.com/OSC/bc_example_jupyter/blob/94d29b4ba705cfe3b17df8ce78f584a4a2f986c5/template/before.sh.erb#L32-L33</a><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">but also to wait until the interactive application server is fully launched and listening on this port before creating the "Connect to Jupyter" button for the user to connect to:<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><a href="https://github.com/OSC/bc_example_jupyter/blob/94d29b4ba705cfe3b17df8ce78f584a4a2f986c5/template/after.sh#L4-L12">https://github.com/OSC/bc_example_jupyter/blob/94d29b4ba705cfe3b17df8ce78f584a4a2f986c5/template/after.sh#L4-L12</a><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">In fact, it is this latter snippet of code where you are seeing the timeout occur. That Bash function `port_used()` in the first link is failing to detect any port in use without netcat installed.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">You have a few options to choose from for resolving this, take your pick:<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">- install netcat on the compute nodes (easiest)<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">- override the Bash function `port_used()` in your `template/before.sh.erb` script before the `find_port` function is called with your own implementation that doesn't use netcat (medium difficulty, note that it isn't documented but there
 is a way to make this a global override for all interactive apps)<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">- remove the timeout conditional in the `template/after.sh` script and just sleep an appropriate amount of time until you are sure the interactive server is running (easy, but possibly bad user experience)<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">-Jeremy Nicklas<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"> <o:p></o:p></p>
<div>
<div>
<p class="MsoNormal">On Thu, Oct 25, 2018 at 10:08 AM E.M. Dragowsky via OOD-users <<a href="mailto:ood-users@lists.osc.edu">ood-users@lists.osc.edu</a>> wrote:<o:p></o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0in;margin-bottom:5.0pt">
<div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt">Greetings --<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt">In implementation of the Jupyter app, I have indications that nc is necessary for connections to compute nodes. The install documentation indicates that it may be used to test that reverse proxy connections
 are successfully configured (3.3 Verify it works)<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt">The compute nodes in our cluster (rhel7) do not have the 'nmap-ncat' package installed. When the package is installed, connections succeed. Without the package -- the connection times-out.
<br>
<br>
I've done this on a subset of our nodes, and am preparing a 'change request' to have the 'nmap-ncat' package installed on all the nodes. Please let me know if I am only seeing part of the picture, or if what I describe indicates other problems with my implementation
 of the interactive jupyter app.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">Thanks,<br clear="all">
<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">~ Em<o:p></o:p></p>
</div>
<p class="MsoNormal"><br>
-- <o:p></o:p></p>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Comic Sans MS"">E.M. Dragowsky, Ph.D.</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Comic Sans MS"">Research Computing -- UTech</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Comic Sans MS"">Case Western Reserve University</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Comic Sans MS""><a href="tel:(216)%20368-0082" target="_blank">(216) 368-0082</a></span><o:p></o:p></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<p class="MsoNormal">_______________________________________________<br>
OOD-users mailing list<br>
<a href="mailto:OOD-users@lists.osc.edu" target="_blank">OOD-users@lists.osc.edu</a><br>
<a href="https://lists.osu.edu/mailman/listinfo/ood-users" target="_blank">https://lists.osu.edu/mailman/listinfo/ood-users</a><o:p></o:p></p>
</blockquote>
</div>
</div>
</body>
</html>