Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error 213 and UnicodeEncodeError #115

Open
jovanbulck opened this issue Jun 8, 2016 · 10 comments
Open

Error 213 and UnicodeEncodeError #115

jovanbulck opened this issue Jun 8, 2016 · 10 comments
Labels

Comments

@jovanbulck
Copy link
Collaborator

jovanbulck commented Jun 8, 2016

From @Wouter92 :

Kotnetverbinding testen... [ OK ]
Gegevens ophalen.......... [ OK ]
Gegevens opsturen......... [ OK ]
Gegevens verwerken........ [FAIL]
Inloggen.................. [FAIL]
ERROR::De netlogin server geeft een onbekende rc-code '213' terug. Contacteer de kotnetcli developers om ondersteuning te krijgen.
[FAIL]
Inloggen.................. [FAIL]
ERROR::Internal kotnetcli exception. Contacteer de kotnetcli developers om ondersteuning te krijgen.
====== TRACEBACK BELOW ======
Traceback (most recent call last):
  File "$KOTNETCLI/kotnetcli/kotnetcli/worker.py", line 47, in go
    self.do_work(co, creds)
  File "$KOTNETCLI/kotnetcli/kotnetcli/worker.py", line 97, in do_work
    self.login_resultaten(co)
  File "$KOTNETCLI/kotnetcli/kotnetcli/worker.py", line 134, in login_resultaten
    co.eventFailureUnknownRC(rccode, html)
  File "$KOTNETCLI/kotnetcli/kotnetcli/communicator/quietc.py", line 150, in eventFailureUnknownRC
    self.print_err_info(self.err_info_rc.format(html=html))
UnicodeEncodeError: 'ascii' codec can't encode character u'\xef' in position 7371: ordinal not in range(128)
====== END OF TRACEBACK ======
@jovanbulck jovanbulck added the bug label Jun 8, 2016
@jovanbulck
Copy link
Collaborator Author

jovanbulck commented Jun 8, 2016

Ok, interesting things going on:

  • I'll look into the UnicodeEncodeError later. Probably easy to fix -- these kind of troubles will hopefully go away when migrating to Python3...
  • We had not yet discovered the server-side rc-code 213. Can you reproduce this? It would be very nice to get a HTML dump for this one, but the Unicode is getting in the way apparently ;-)

Could you try to get a manual HTML dump, maybe by uncommenting line 134 in browser.py? Also could you post the output of kotnetcli --debug?

@jovanbulck jovanbulck changed the title Rc213 and UnicodeEncodeError Error 213 and UnicodeEncodeError Jun 8, 2016
@Wanimatrix
Copy link
Contributor

Debug result with HTML-dump (apparently I have no permission to use Kotnet :P):

DEBUG::kotnetcli: parse_args() is: Namespace(communicator=None, debug='debug', forget=False, guest_mode=False, institution=None, keyring=False, license=None, login=False, logout=False, time=False, version=None)
INFO::kotnetcli: ik haal de credentials uit de keyring
INFO::kotnetcli: ik wil inloggen
INFO::kotnetcli: ik ga mee met de stroom
DEBUG::worker: Enter worker.go()
DEBUG::worker: got creds for user r0255785@kotnetext
Kotnetverbinding testen... [ OK ]
Gegevens ophalen.......... INFO::connectionpool: Starting new HTTPS connection (1): netlogin.kuleuven.be
DEBUG::connectionpool: "GET /cgi-bin/wayf2.pl?lang=nl&inst=kotnetext&submit=Ga+verder+%2F+Continue HTTP/1.1" 200 None
[ OK ]
Gegevens opsturen......... INFO::connectionpool: Starting new HTTPS connection (1): netlogin.kuleuven.be
DEBUG::connectionpool: "POST /cgi-bin/netlogin.pl HTTP/1.1" 200 None
DEBUG::browser: HTTP POST RESPONSE FROM SERVER is:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="nl" lang="nl">
<head>
<title>Netwerk Login</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="Description" content="KU Leuven, " />
<meta name="Keywords" content="KU Leuven, Katholieke Universiteit Leuven, " />
<style type="text/css" media="screen, projection">
@import url(https://stijl.kuleuven.be/_c/subnav.css);
@import url(https://stijl.kuleuven.be/_c/nieuws.css);
/* embedded styles hier */
</style>
<link rel="stylesheet" type="text/css" href="https://stijl.kuleuven.be/_c/main.css" title="default" media="screen, projection" />
<!--[if lt IE 8]><link rel="stylesheet" type="text/css" href="https://stijl.kuleuven.be/_c/IE.css" media="screen, projection" /><![endif]-->
<link rel="stylesheet" type="text/css" href="https://stijl.kuleuven.be/_c/handheld.css" media="handheld" />
<link rel="stylesheet" type="text/css" href="https://stijl.kuleuven.be/_c/print.css" media="print" />
<link rel="stylesheet" type="text/css" href="/css/style.css" title="default" />
</head>
<body>
<div id="wrapper">
  <div id="header">
<h2 class="access">Taakbalk</h2>
<ul id="access">
        <li><a href="#mainnav" tabindex="1" accesskey="N">navigatie</a></li>
        <li><a href="#subnav" tabindex="2" accesskey="S">subnavigatie</a></li>
        <li><a href="#content" tabindex="3" accesskey="C">inhoud</a></li>
</ul>
<ul id="taskbar">
        <li class="home"><a href="http://www.kuleuven.be/kuleuven/" tabindex="4" id="top" name="top">home</a></li>
        <li class="whoiswho"><a href="http://cwisdb.kuleuven.be/persdb-bin/persdb?lang=N&amp;oproep=vraag">wie is wie</a></li>
        <li class="organigram"><a href="http://organigram.kuleuven.be/">organigram</a></li>
        <li class="contact"><a href="http://www.kuleuven.be/kuleuven/contact.html">contact</a></li>
        <li class="intranet"><a href="http://www.kuleuven.be/intranet/">intranet</a></li>
        <li class="langselect"><a href="http://www.kuleuven.be/english/" title="Choose English">english</a></li>
</ul>
<a href="http://www.kuleuven.be/kuleuven/"><img id="logo" src="https://stijl.kuleuven.be/logo_kuleuven.png" width="160" height="53" alt="logo" title="KU Leuven - Home" /></a>
<form action="http://robot.kuleuven.be/index.cgi" method="post" id="searchform" title="zoekformulier" name="searchform"><label for="words">zoekterm: </label>
<input tabindex="5" type="text" name="words" id="words" title="geef een zoekterm"/><input tabindex="6" type="image" class="magnifier" src="https://stijl.kuleuven.be/_i/icons/icon_magnifier.gif" alt="verstuur" title="zoek nu"/><input type="hidden" name="oproep" value="zoek" />
</form>
</div><!-- end header -->
<div id="subnav">
    <h2><a href="http://admin.kuleuven.be/icts">ICTS</a></h2>
    <ul id="subnavlist">
    <li><a href="http://admin.kuleuven.be/icts/services">Dienstverlening voor de universiteit</a></li>
    <li><a href="https://account.kuleuven.be/activateVoucher.html">Activeer faciliteitenpakket via voucher</a></li><li class="separator"> <br /> </li><li><a href="http://admin.kuleuven.be/icts/helpdesk">Helpdesk</a></li>    </ul>
  </div>


<div id="nieuws">
<div class="indekijker">
            <h3>Meer informatie</h3>
        <ul>
          <li><a href="https://admin.kuleuven.be/icts/services/kotnet" target="_blank">KotNet algemeen</a></li>
          <li><a href="https://admin.kuleuven.be/icts/services/kotnet/gebruiksvoorwaarden" target="_blank">Gedragscode voor KotNet</a></li>
          <li><a href="http://status.kuleuven.be/kuleuvennet" target="_blank">Netwerk status</a></li>
          <li><a href="http://icts.kuleuven.be/help/" target="_blank">Helpdesk</a></li>
        </ul>
</div>
<div class="thema">
            <h3>More information</h3>
        <ul>
          <li><a href="http://ludit.kuleuven.be/internet/index_en.html" target="_blank">KotNet in general</a></li>
          <li><a href="http://ludit.kuleuven.be/internet/kotnet/voorwaarden_en.html" target="_blank">KotNet Use Policy</a></li>
          <li><a href="http://status.kuleuven.be/kuleuvennet" target="_blank">Network status</a></li>
          <li><a href="http://icts.kuleuven.be/help/index_en.html" target="_blank">Helpdesk</a></li>
        </ul>
</div>
</div>

  <div id="contentwrapper">
    <div id="content">
      <!-- content starts here -->
                  <!--<div id="navbar"><span style="display: none">Navigatiebalk: </span><a href="/">Home</a> &gt; <a href="/leeg/">Leeg</a></div> -->


<h1>KotNet</h1>
<h2>Netwerk Login</h2>
        <div class="associatie_logo">
                  <img src="/images/associatie_logo.gif" width="44" height="62" border="0"/>
        </div>

<h2>KotNet</h2>
<!-- <rc=100 password verification successful (user=<kotnetext/r0255785>)>
 -->
<H1>Resultaat Netwerk Login</H1>
<!-- weblogin: rc=213 -->
<HR>
           <FONT size="+2" color="red">Login NIET geslaagd.</FONT><P>
           <B>213</B> : de gebruiker r0255785 heeft geen toelating om
               KotNet te gebruiken. Voor registratie, contacteer je instelling.
        <HR size=1 noshade>
            <P>
            <TABLE border="1" align="center" width="80%">
            <TR>
            <TD bgcolor="#6666cc">
            <FONT color="white" face="sans-serif" size="+1">
            <CENTER><B>boodschap voor deze dag</B></CENTER>
            </FONT>
            </TD>
            </TR>
            <TR>
            <TD>
            <!-- weblogin: motd start -->
        <p>
<b>KHLeuven en KotNet</b>
<br>
<a href="http://portaal.khleuven.be/index.php?page=256" target="_blank">Kotnet&nbsp;</a>is momenteel voor iedereen beschikbaar als eenmalige overgangsmaatregel.
<b>Na 8 november 2013</b> zullen enkel personeelsleden en studenten waarvoor een betaling werd geregistreerd gebruik kunnen maken van Kotnet.<br>
Je kan via <a href="https://portaal.khleuven.be/index.php">het portaal</a> &quot;Tools &gt; Aanbod&quot;&nbsp;<a href="https://portaal.khleuven.be/index.php?page=379" target="_blank">Kotnet aanvragen</a>&nbsp;en via &quot;Tools &gt; Aanbod deelnames&quot;&nbsp;kan je de&nbsp;<a href="http://portaal.khleuven.be/index.php?page=376">status
 van je betaling raadplegen</a>. Hou er rekening mee dat het wat tijd in beslag neemt eer je betaling geregistreerd is.
</p>

<p>
<b>Host isolation op KotNet residenties</b>
<br>
Vanaf 13 februari 2013 kunnen 2 computers die op een KU Leuven residentie verbonden zijn met KotNet niet langer rechtstreeks met elkaar communiceren. Dit doen we om het hoofd te bieden aan nieuwe veiligheidsrisico's.<br>

Tot nu toe vormden verschillende computers op een KU Leuven residentie samen een lokaal netwerk, waarbij de computers rechtstreeks met elkaar konden "praten". Dit maakte o.a. bestandsdeling via een lokaal Windows netwerk mogelijk.<br>
KU Leuven bereidt zich samen met vele andere netwerken wereldwijd voor op de introductie van IPv6, een architectuur die nieuwe mogelijkheden opent, maar ook nieuwe beveiligingsrisico's met zich meebrengt. Computers die rechtstreeks verbonden zijn met elkaar op een IPv6-netwerk, zijn kwetsbaar voor gerichte aanvallen.<br>
Daarom wordt elke host (computer) op het netwerk voortaan geïsoleerd, waarbij er enkel nog verkeer tussen de host en internet mogelijk is. Het is daarbij niet langer mogelijk om rechtstreeks verkeerr
 tussen 2 pc's op dat netwerk te hebben.<br>
Het normale verkeer naar internet, zoals surfen, e-mailen, bestandsdeling via bv. Dropbox, chatten, ... ondervindt hiervan geen hinder.<br>
</p>

<p>
<b>Herinnering: accounts zijn strikt persoonlijk</b>
<br>
Het gebruik van je login account is strikt persoonlijk en als eigenaar ben jij zelf verantwoordelijk voor alle acties of misbruiken die gebeuren met jouw account.<br>
Bijgevolg is het dus ook niet toegestaan om je login account door anderen te laten gebruiken!<br>
Wanneer je misbruik vermoedt met je account, wijzig dan onmiddellijk je wachtwoord op <a href="http://wachtwoord.kuleuven.be">http://wachtwoord.kuleuven.be</a>.
</p>

            <!-- weblogin: motd end -->
            </TD>
            </TR>
            </TABLE>
            <P>
        <HR>

          <TABLE width="100%"><TR>
          <TD><H3><A name="techinfo">Technische informatie</A></H3></TD>
          <TD align=right><A href="#top"><FONT size="-4">[Top]</FONT></A></TD>
          </TR></TABLE>
          <P>

        intranet userid = kotnetext/r0255785</BR>
        email = [email protected]<BR>
        site = nil<BR>
        ip-addr = 10.92.238.19<BR>
        subnet = nil<BR>
        mask = nil<BR>
        router = nil<BR>
        message = login failed for kotnetext/[email protected]
    <P>
Laatste 10 logins:<BR>

        <P>
        <TABLE>
        <TR><TD><PRE></PRE></TD></TR>
        </TABLE>
        <P>
    Gebruiker kotnetext/r0255785 is ingelogd op de volgende ip adressen:<BR>
<TABLE>
</TABLE>

      <!-- content ends here -->
    </div>
  </div>
  <!--end contentwrapper-->
  <div id="footer">
     <p>Copyright &copy; KU Leuven | reacties op de inhoud: <a href="mailto:[email protected]">ICTS</a><br />
      Realisatie: <a href="mailto:[email protected]">ICTS</a>| <a href="http://www.kuleuven.be/kuleuven/disclaimer.html">Disclaimer</a>
                  </p>
  </div>
</div>

</body>
</html>


[ OK ]
Gegevens verwerken........ DEBUG::browser: rccode is 213
[FAIL]
Inloggen.................. [FAIL]
ERROR::De netlogin server geeft een onbekende rc-code '213' terug. Contacteer de kotnetcli developers om ondersteuning te krijgen.
DEBUG::worker: Caught worker exception; exiting with failure
[FAIL]
Inloggen.................. [FAIL]
ERROR::Internal kotnetcli exception. Contacteer de kotnetcli developers om ondersteuning te krijgen.
====== TRACEBACK BELOW ======
Traceback (most recent call last):
  File "$KOTNETCLI/kotnetcli/kotnetcli/worker.py", line 47, in go
    self.do_work(co, creds)
  File "$KOTNETCLI/kotnetcli/kotnetcli/worker.py", line 97, in do_work
    self.login_resultaten(co)
  File "$KOTNETCLI/kotnetcli/kotnetcli/worker.py", line 134, in login_resultaten
    co.eventFailureUnknownRC(rccode, html)
  File "$KOTNETCLI/kotnetcli/kotnetcli/communicator/quietc.py", line 150, in eventFailureUnknownRC
    self.print_err_info(self.err_info_rc.format(html=html))
UnicodeEncodeError: 'ascii' codec can't encode character u'\xef' in position 7371: ordinal not in range(128)
====== END OF TRACEBACK ======

@Wanimatrix
Copy link
Contributor

Also, sometimes I get the error above, but other times I get ERROR::Connection attempt to netlogin service 'netlogin.kuleuven.be:443' timed out. Are you on the kotnet network?.
Maybe these two are somehow related?

@jovanbulck
Copy link
Collaborator Author

Ok, seems like rc 213 is the KotNet equivalent of the recently discovered rc 214 CampusNet code (issue #113 ). Still weird that you get this rc code, though. Not sure, but maybe it has something to do with the "a-number"? Do you get the errorcode when logging in via a webbrowser (with your r-number)?

Also, sometimes I get the error above, but other times I get ERROR::Connection attempt to netlogin service 'netlogin.kuleuven.be:443' timed out. Are you on the kotnet network?.
Maybe these two are somehow related?

Nope, you get this error message because one of the connection requests timed out. The timeout for all server connections is set in BROWSER_TIMEOUT_SEC in browser.py, and defaults to 1.5 sec. Apparently, this default value is a bit to conservative for slow connections ;-) We'll thus better increase it, but not too much of course (to provide good error messages for users not connected to the KotNet network). Feel free to experiment with this value and report a better one!

@jovanbulck
Copy link
Collaborator Author

A closer look reveals the likely cause of your rc code:

DEBUG::worker: got creds for user r0255785@kotnetext

As in, you're using the kotnetext institution, whereas you should be using kuleuven (the default). Institution choice in nowadays stored in the credentials, so either:

  1. kotnetcli --forget your current credentials, and kotnetcli will prompt you for new ones the next time
  2. kotnetcli --guest to prompt for new credentials this session only
  3. kotnetcli --institution to override the keyring institution for this session only

Let me know if that fixes it...

@Wanimatrix
Copy link
Contributor

Ok, I was somehow convinced I needed kotnetext. But no, so everything works now.

For the timeout value: maybe it's better to take a waterfall approach? So, every time it fails the timeout is doubled until a max is reached and when it fails even with the maximum timeout the error is raised.

@jovanbulck
Copy link
Collaborator Author

Ok, I was somehow convinced I needed kotnetext. But no, so everything works now.

Nice. We might consider changing the standard prompt to make the default choice more clear.

For the timeout value: maybe it's better to take a waterfall approach? So, every time it fails the timeout is doubled until a max is reached and when it fails even with the maximum timeout the error is raised.

As far as I see, it's better to grant the maximum timeout at once. The above approach only increases the end user's waiting time, without additional benefits -- the maximum timeout is granted in the end anyway.

@jovanbulck
Copy link
Collaborator Author

@Wouter92 As for the UnicodeEncodeError, I cannot (for now) find a clean and portable way of fixing this in the source code. The behaviour can be adjusted via the PYTHONIOENCODING environment variable. Could you try the following (maybe add it to your ~/.bash_profile):

export PYTHONIOENCODING=utf-8

@jovanbulck
Copy link
Collaborator Author

We might consider changing the standard prompt to make the default choice more clear.

Done 5a49dc9

screenshot_2016-06-12_18-43-05

jovanbulck added a commit that referenced this issue Jan 7, 2017
Encoding the HTML string in utf8 before passing it on to the
communicator for printing should fix issue #115.
@jovanbulck
Copy link
Collaborator Author

@Wouter92 Could you verify whether recent commit f71b37f fixes the Unicode erorrs on you system?

Running kotnetcli --institution kotnetext for example should fail gracefully, dumping the HTML page on stdout.

jovanbulck added a commit that referenced this issue Jan 11, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants