在RethinkDB中使用'idna'编解码器编码失败 [英] Encoding with 'idna' codec failed in RethinkDB

查看:95
本文介绍了在RethinkDB中使用'idna'编解码器编码失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 flask 应用程序,该应用程序运行并连接到 pythonanywhere.com ,但是此部署不断引发以下错误:

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)

连接代码如下所示:

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.

运行Python 3.5.

Running Python 3.5.

推荐答案

idna编解码器正在尝试将rethinkdb URL转换为与ascii兼容的等效字符串.

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

这对我有用:

"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.

或者,您可以使用连接字符串在Python shell中进行编码,并逐渐简化它,直到找到有问题的片段为止.

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).

这篇关于在RethinkDB中使用'idna'编解码器编码失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆