Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/337.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 客户端向HTTPS服务器发送了HTTP请求_Python_Docker_Kubernetes_Https_Influxdb - Fatal编程技术网

Python 客户端向HTTPS服务器发送了HTTP请求

Python 客户端向HTTPS服务器发送了HTTP请求,python,docker,kubernetes,https,influxdb,Python,Docker,Kubernetes,Https,Influxdb,我有一个在虚拟机上运行的python应用程序,这是一个遗留问题,现在我要迁移到Kubernetes 我使用influxdb==5.2.3包,连接到此表单Influx(主机=r'Influx\u主机,端口=8086,用户名='MY\u用户',密码='***',数据库='DB\u名称',ssl=True)。这个python脚本使用SSL证书调用InfluxBD,当我直接使用python app.py运行时,它运行得很好,但问题是: 我已停靠,脚本显示以下错误。 库伯内特斯部署 apiVersion:

我有一个在虚拟机上运行的python应用程序,这是一个遗留问题,现在我要迁移到Kubernetes

我使用
influxdb==5.2.3
包,连接到此表单
Influx(主机=r'Influx\u主机,端口=8086,用户名='MY\u用户',密码='***',数据库='DB\u名称',ssl=True)
。这个python脚本使用SSL证书调用InfluxBD,当我直接使用
python app.py运行时,它运行得很好,但问题是:

我已停靠,脚本显示以下错误。 库伯内特斯部署

apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-ms
spec:
  replicas: 1
  selector:
    matchLabels:
      ip-service: my-ms
  template:
    metadata:
      labels:
        ip-service: my-ms
    spec:
      containers:
        - name: my-ms
          image: myprivate.azurecr.io/my-ms:latest
          ports:
            - containerPort: 8080
          resources:
            requests:
              cpu: 100m
              memory: 10Mi
      imagePullSecrets:
        - name: tecnoregistry
编辑2 我在Kubernetes上得到了与我相同的错误,但是在本地运行脚本时,我将服务调用
Influx(host=r'Influx\u host',port=8086,username='MY\u USER',password='***',database='DB\u NAME',SSL=False)中的SSL值从True更改为False

~$python3 app.py
回溯(最近一次呼叫最后一次):
文件“/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site packages/urllib3/response.py”,第360行,在“错误捕捉器”中
产量
文件“/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site packages/urllib3/response.py”,第442行,已读
数据=自计量读数(金额)
文件“/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py”,第457行,已读
n=自读入(b)
readinto中第501行的文件“/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py”
n=自fp读入(b)
readinto中的文件“/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/socket.py”,第589行
返回自我。将袜子重新放入(b)
ConnectionResetError:[Errno 54]对等方重置连接
在处理上述异常期间,发生了另一个异常:
回溯(最近一次呼叫最后一次):
文件“/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site packages/requests/models.py”,第750行,在generate中
对于self.raw.stream中的块(块大小,解码内容=True):
文件“/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site packages/urllib3/response.py”,第494行,在流中
数据=自读(金额=金额,解码内容=解码内容)
文件“/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site packages/urllib3/response.py”,第459行,已读
提升未完成读取(self.\u fp\u字节\u读取,self.length\u剩余)
文件“/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/contextlib.py”,第130行,在退出时__
self.gen.throw(类型、值、回溯)
文件“/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site packages/urllib3/response.py”,第378行,在“错误捕捉器”中
引发协议错误('连接断开:%r'%e,e)
urllib3.exceptions.ProtocolError:(“连接断开:ConnectionResetError(54,‘由对等方重置连接’)”,ConnectionResetError(54,‘由对等方重置连接’))
在处理上述异常期间,发生了另一个异常:
回溯(最近一次呼叫最后一次):
文件“app.py”,第1272行,在
生成卓越消费()
文件“/Volumes/DATA/IdeaProjects/australia/analitica\u py\u sw\u reclect\u info/calculo\u excels.py”,第206行,在generate\u excels\u consumo中
df\u扇区=流入\u KPI。多个\u查询\u到\u多个\u df(查询)
文件“/Volumes/DATA/IdeaProjects/australia/analitica_py_sw_reclect_info/analitica_py_lib_conexions/conexion_influx.py”,第126行,在多个查询中
resultado=self.\u cliente.query(“;”.join(query))
文件“/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site packages/influxdb/client.py”,查询中第450行
预期\u响应\u代码=预期\u响应\u代码
请求中的文件“/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site packages/influxdb/client.py”,第283行
超时=自身。\u超时
文件“/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site packages/requests/sessions.py”,请求中第533行
resp=自我发送(准备,**发送)
文件“/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site packages/requests/sessions.py”,第686行,在send中
r、 内容
content中的文件“/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site packages/requests/models.py”,第828行
self.\u content=b“”。加入(self.iter\u content(content\u CHUNK\u SIZE))或b“”
文件“/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site packages/requests/models.py”,第753行,在generate中
raise ChunkedEncodingError(e)
requests.exceptions.ChunkedEncodingError:(“连接断开:ConnectionResetError(54,‘对等方重置连接’)”,ConnectionResetError(54,‘对等方重置连接’))

似乎是网络问题。由于代理,我在连接MongoDB时遇到了斯迈勒问题。任何事情都可能发生在这个问题上

默认情况下,Docker运行的每个容器都有自己的网络名称空间

提供一些解决方法:

  • traceroute
    执行此命令,并检查是否到达容器附件容器内的集群,并执行命令
    docker exec-it container/bin/bash
  • 检查代理<代码>导出
  • 检查与代理相关的环境变量
  • curl www.google.com
  • 尝试连接群集中的其他事物。例如MySQL等(有一次机器自动给我写黑名单,我试着在2天内解决连接问题)
  • 尝试使用python slim图像。slim图像基于ubuntu
  • 这是理解和解决docker连接问题的很好的文档


    您能展示dockerfile和kubernetes部署yaml吗?@Fauzan Done!;)
    Traceback (most recent call last):
      File "/usr/local/lib/python3.8/site-packages/urllib3/response.py", line 360, in _error_catcher
        yield
      File "/usr/local/lib/python3.8/site-packages/urllib3/response.py", line 442, in read
        data = self._fp.read(amt)
      File "/usr/local/lib/python3.8/http/client.py", line 454, in read
        n = self.readinto(b)
      File "/usr/local/lib/python3.8/http/client.py", line 498, in readinto
        n = self.fp.readinto(b)
      File "/usr/local/lib/python3.8/socket.py", line 669, in readinto
        return self._sock.recv_into(b)
    ConnectionResetError: [Errno 104] Connection reset by peer
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "/usr/local/lib/python3.8/site-packages/requests/models.py", line 750, in generate
        for chunk in self.raw.stream(chunk_size, decode_content=True):
      File "/usr/local/lib/python3.8/site-packages/urllib3/response.py", line 494, in stream
        data = self.read(amt=amt, decode_content=decode_content)
      File "/usr/local/lib/python3.8/site-packages/urllib3/response.py", line 459, in read
        raise IncompleteRead(self._fp_bytes_read, self.length_remaining)
      File "/usr/local/lib/python3.8/contextlib.py", line 131, in __exit__
        self.gen.throw(type, value, traceback)
      File "/usr/local/lib/python3.8/site-packages/urllib3/response.py", line 378, in _error_catcher
        raise ProtocolError('Connection broken: %r' % e, e)
    urllib3.exceptions.ProtocolError: ("Connection broken: ConnectionResetError(104, 'Connection reset by peer')", ConnectionResetError(104, 'Connection reset by peer'))
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "app.py", line 591, in <module>
        get_horas_stock()
      File "app.py", line 513, in get_horas_stock
        df_temp = influx_temperatura.multiple_query_to_df(queries_temperatura)
      File "/usr/src/app/analitica_py_lib_conexiones/conexion_influx.py", line 82, in multiple_query_to_df
        resultado = self.__cliente.query(";".join(queries))
      File "/usr/local/lib/python3.8/site-packages/influxdb/client.py", line 445, in query
        response = self.request(
      File "/usr/local/lib/python3.8/site-packages/influxdb/client.py", line 274, in request
        response = self._session.request(
      File "/usr/local/lib/python3.8/site-packages/requests/sessions.py", line 533, in request
        resp = self.send(prep, **send_kwargs)
      File "/usr/local/lib/python3.8/site-packages/requests/sessions.py", line 686, in send
        r.content
      File "/usr/local/lib/python3.8/site-packages/requests/models.py", line 828, in content
        self._content = b''.join(self.iter_content(CONTENT_CHUNK_SIZE)) or b''
      File "/usr/local/lib/python3.8/site-packages/requests/models.py", line 753, in generate
        raise ChunkedEncodingError(e)
    requests.exceptions.ChunkedEncodingError: ("Connection broken: ConnectionResetError(104, 'Connection reset by peer')", ConnectionResetError(104, 'Connection reset by peer'))
    
    FROM python:3.8.2-buster
    
    WORKDIR /usr/src/app
    
    COPY . .
    
    RUN pip install --no-cache-dir -r requirements.txt
    
    EXPOSE 8080
    
    CMD ["python", "app.py"]
    
    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: my-ms
    spec:
      replicas: 1
      selector:
        matchLabels:
          ip-service: my-ms
      template:
        metadata:
          labels:
            ip-service: my-ms
        spec:
          containers:
            - name: my-ms
              image: myprivate.azurecr.io/my-ms:latest
              ports:
                - containerPort: 8080
              resources:
                requests:
                  cpu: 100m
                  memory: 10Mi
          imagePullSecrets:
            - name: tecnoregistry
    
    ~$ python3 app.py
    Traceback (most recent call last):
      File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/urllib3/response.py", line 360, in _error_catcher
        yield
      File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/urllib3/response.py", line 442, in read
        data = self._fp.read(amt)
      File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 457, in read
        n = self.readinto(b)
      File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 501, in readinto
        n = self.fp.readinto(b)
      File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/socket.py", line 589, in readinto
        return self._sock.recv_into(b)
    ConnectionResetError: [Errno 54] Connection reset by peer
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/requests/models.py", line 750, in generate
        for chunk in self.raw.stream(chunk_size, decode_content=True):
      File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/urllib3/response.py", line 494, in stream
        data = self.read(amt=amt, decode_content=decode_content)
      File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/urllib3/response.py", line 459, in read
        raise IncompleteRead(self._fp_bytes_read, self.length_remaining)
      File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/contextlib.py", line 130, in __exit__
        self.gen.throw(type, value, traceback)
      File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/urllib3/response.py", line 378, in _error_catcher
        raise ProtocolError('Connection broken: %r' % e, e)
    urllib3.exceptions.ProtocolError: ("Connection broken: ConnectionResetError(54, 'Connection reset by peer')", ConnectionResetError(54, 'Connection reset by peer'))
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "app.py", line 1272, in <module>
        generate_excels_consumo()
      File "/Volumes/DATA/IdeaProjects/australia/analitica_py_sw_recolect_info/calculo_excels.py", line 206, in generate_excels_consumo
        df_sector = influx_kpis.multiple_query_to_multiple_df(queries)
      File "/Volumes/DATA/IdeaProjects/australia/analitica_py_sw_recolect_info/analitica_py_lib_conexiones/conexion_influx.py", line 126, in multiple_query_to_multiple_df
        resultado = self.__cliente.query(";".join(query))
      File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/influxdb/client.py", line 450, in query
        expected_response_code=expected_response_code
      File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/influxdb/client.py", line 283, in request
        timeout=self._timeout
      File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/requests/sessions.py", line 533, in request
        resp = self.send(prep, **send_kwargs)
      File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/requests/sessions.py", line 686, in send
        r.content
      File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/requests/models.py", line 828, in content
        self._content = b''.join(self.iter_content(CONTENT_CHUNK_SIZE)) or b''
      File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/requests/models.py", line 753, in generate
        raise ChunkedEncodingError(e)
    requests.exceptions.ChunkedEncodingError: ("Connection broken: ConnectionResetError(54, 'Connection reset by peer')", ConnectionResetError(54, 'Connection reset by peer'))