pyrebase4 HTTPConnectionPool 最大重试次数超过 url NewConnectionError 建立新连接失败 getaddrinfo failed

问题描述

我正在创建 python django web 应用程序来上传 firebase 实时数据库上的数据。 我正在使用 python3 和 pyrebase4。 Firebase 身份验证已完成。 用户登录登录程序已完成。 我在第三步中遇到了错误,即在实时数据库上传数据。
显示运行时错误的行是:

db.child('users').child(a).child('reports').child(millis).set(data)

运行时错误是:

httpconnectionPool Max retries exceeded with url: /%5B'localId'%5D/reports/1617203893.json 
Caused by NewConnectionError('<urllib3.connection.httpconnection object at 0x000001C44758D8E0>: 
Failed to establish a new connection: [Errno 11001] getaddrinfo Failed'))

views.py

from django.shortcuts import render
from django.contrib import auth
import pyrebase


config={

    'apiKey': "AIzaSyDWBmMMaF3YJO7ZxMXgbBRzqw7hqe564vc",'databaseURL': 'http://'+'','authDomain': "cpanel-103d6.firebaseapp.com",'projectId': "cpanel-103d6",'storageBucket': "cpanel-103d6.appspot.com",'messagingSenderId': "489072871004",'appId': "1:489072871004:web:fd717d9bd6d0a4007f4899","serviceAccount": "C:/Users/Subijoy Acharya/Videos/cpanel-103d6-firebase-adminsdk-l3x1i-7c7fca8614.json"

}


firebase= pyrebase.initialize_app(config)
db= firebase.database()
authe =firebase.auth()

def signin(request):
    return render(request,"signin.html")

def postsign(request):
    email = request.POST.get('email')
    passw = request.POST.get('pass')

    try:
        user = authe.sign_in_with_email_and_password(email,passw)
    except:
        message = 'invalid credentials'
        return render(request,'signin.html',{'messg': message})

    print(user['idToken'])
    session_id= user['idToken']
    request.session['uid']=str(session_id)
    return render(request,'welcome.html',{'e': email})

def logout(request):
    auth.logout(request)
    return render(request,'signin.html')

def signup(request):
    return render(request,'signup.html')

def postsignup(request):
    name=request.POST.get('name')
    email=request.POST.get('email')
    password= request.POST.get('passw')
    user=authe.create_user_with_email_and_password(email,password)
    uid = user['localId']
    data={"name":name,"status":'1'}
    db.child("users").set(uid).child('details').set(data)

    return render(request,"signin.html")

def create(request):
    return render(request,"create.html")

def post_create(request):
    import time
    from datetime import datetime,timezone
    import pytz

    tz= pytz.timezone('Asia/Kolkata')
    timeNow= datetime.Now(timezone.utc).astimezone()
    millis=int(time.mktime(timeNow.timetuple()))
    print('mili'+str(millis))
    work=request.POST.get('work')
    progress=request.POST.get('progress')
    idtoken=request.session['uid']
    a=authe.get_account_info(idtoken)
    a=a['users']
    a=a[0]
    a=['localId']
    print('info'+str(a))
    data={
        "work":work,"progress":progress
    }

    db.child('users').child(a).child('reports').child(millis).set(data)

    return render(request,'welcome.html')

create.html

<!DOCTYPE html>
<html lang="en">

<head>
    <Meta charset="UTF-8">


</head>
<body>
    <h1>Dear User,Upload Document Here</h1>

  <form action="/post_create/" method="post">
      {% csrf_token %}
      Work Assigned : <input type = "text" name="work" required>
      Progress : <textarea rows="5" cols="40" name="progress" required></textarea>
      <br><br>
      <input type="submit" value="SUBMIT">
      <button type="button" onclick="location.href='{% url 'signup' %}'">Sign Up</button>
  </form>
    <br><br>
  <div><button type="button" onclick="location.href='{% url 'log' %}'"> logoUT </button></div>

</body>
</html>

urls.py

from django.contrib import admin
from django.urls import path
from . import views
urlpatterns = [
    path('admin/',views.signin),path('postsign/',views.postsign),path('logout/',views.logout,name='log'),path('signup/',views.signup,name='signup'),path('postsignup/',views.postsignup,name='postsignup'),path('create/',views.create,name='create'),path('post_create/',views.post_create,name='post_create')
]

链接中给出的 pyrebase 文档: https://github.com/thisbejim/Pyrebase

这是我参考的视频: https://www.youtube.com/watch?v=bq0AszeDZf4&list=PLhPDb5zFmGR2VfXiN2y-1V0qdRik7Cc0K&index=4

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...