Encoding with 'idna' codec failed in RethinkDB

纵饮孤独 提交于 2020-03-03 08:48:12

问题


I have a flask app that runs and connects to a remote rethinkdb database on compose.io. The app is also deployed to pythonanywhere.com, but this deployment keeps throwing the following error:

Traceback (most recent call last):
File "/home/user/.virtualenvs/venv/lib/python3.5/encodings/idna.py", line 165, in encode
    raise UnicodeError("label empty or too long")
UnicodeError: label empty or too long

...

rethinkdb.errors.ReqlDriverError: Could not connect to rethinkdb://[user]:[password]@aws-us-east-1-portal.1.dblayer.com:23232. Error: encoding with 'idna' codec failed (UnicodeError: label empty or too long)

The connection code looks exactly like this:

conn = r.connect(host='aws-us-east-1-portal.1.dblayer.com',  
             port=23232,
             auth_key='[auth_key]',
             ssl={'ca_certs': './cacert'})

I'm not sure how to proceed from here.

Running Python 3.5.


回答1:


The idna codec is attempting to convert your rethinkdb URL into an ascii-compatible equivalent string.

This worked for me:

"rethinkdb://user:password@aws-us-east-1-portal.1.dblayer.com:23232".encode("idna")

So my guess is that some character/sequence of characters in your username or password is causing the issue. Try the connection with a (possibly bogus) very simple password and see if you get the same issue.

Alternatively, you could do the encode in a Python shell with the connection string and gradually simplify it until you identify the problematic piece(s).



来源:https://stackoverflow.com/questions/39465259/encoding-with-idna-codec-failed-in-rethinkdb

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!