- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试从 localhost:5000 上托管的 python 服务器向 RabbitMQ 服务器发送消息(使用 RabbitMQ 的 docker 镜像),但出现以下错误:
socket.gaierror gaierror: [Errno -2] Name or service not known
我正在使用命令运行 RabbitMQ 的 docker 镜像,其中“rabbithost”是我使用的主机名:
sudo docker run -d --hostname rabbithost --name rabbitmq -p 15672:15672 -p 5672:5672 -p 5671:5671 rabbitmq:3-management
这是给出错误的 python 代码:
def send_to_queue(message):
credentials = pika.PlainCredentials('guest', 'guest')
parameters = pika.ConnectionParameters('rabbithost', 5672, '/', credentials)
connection = pika.BlockingConnection(parameters)
channel = connection.channel()
channel.queue_declare(queue='hello')
channel.basic_publish(exchange='', routing_key='hello',body=message)
connection.close()
return "Message Sent! "
错误在行:
connection = pika.BlockingConnection(parameters)
主要是因为parameters参数。我无法找到此错误的确切解决方案。
最佳答案
python代码在哪里运行?在本地主机上?如果是,那么您需要将 rabbithost
更改为 127.0.0.1
或在 /etc/hosts
中为 127.0 创建一个主机条目。 0.1 兔子主机
关于python - 套接字.gaierror gaierror : [Errno -2] Name or service not known - pika rabbitMQ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46187647/
我正在尝试从 localhost:5000 上托管的 python 服务器向 RabbitMQ 服务器发送消息(使用 RabbitMQ 的 docker 镜像),但出现以下错误: socket.gai
我今天在尝试通过发送“GET”HTTP 请求来检索 XML 时遇到错误。 from httplib import HTTPConnection import urllib params = urlli
我正在尝试用 python 制作一个非常基本的 FTP 客户端,在前几行代码中我已经遇到了问题 我的代码: from ftplib import FTP ftp = FTP('ftp.mysite.c
我正在使用 python 的请求库,我希望代码在此 ('Connection aborted.', gaierror(-2, 'Name or service not known')) 时继续运行。发
我有这个非常简单的代码: print(socket.gethostbyname(socket.gethostname())) 那应该是我的IP地址。 但是它返回一个错误: socket.gaierro
我是 python 新手,正在阅读一本书,Core Python Applications 3rd Edition。这是第一个例子,我已经被它难住了。这是最后有错误的代码。 #!/usr/bin/en
我是新手,正在阅读一本名为《核心Python应用程序第三版》的书。这是第一个例子,我已经被它难住了。以下是代码末尾的错误。。这是什么意思?
几个小时前,我发布了一篇与“Django 电子邮件发送 API”及其错误相关的帖子。所以我想首先我应该尝试使用“smtplib”。不幸的是,在与“smtplib”斗争之后,我意识到它也不会工作,因为我
我在 OS X Yosemite (10.10.3) 上运行 Pycharm 4.5.3。我创建了一个简单的 python 程序,并尝试打开 python 控制台,但得到了这个堆栈跟踪错误: /usr
这一行抛出一个 gaierror...知道为什么吗?会不会是防火墙? smtp=smtplib.SMTP(host=EMAIL_HOST,port=EMAIL_PORT) 我使用的是 gmail,所以
我如何在 Django 或 Python 中正确捕获 gaierror?当向 3rd 方 API 发出请求并且无法建立连接时,会出现此错误。我尝试了一个带有空 except 的 try 但没有捕获到
试图在 python 中创建一个邮件发送器,脚本在我的个人笔记本电脑上运行,但是当我在我的工作笔记本电脑上运行它时(我是最近的实习生)我认为代理妨碍了连接到gmail smtp 服务器 错误如下: F
我尝试使用 python 将文件附加到邮件中。 代码: import smtplib from email.MIMEMultipart import MIMEMultipart from email.
我创建了一个通过MQTT发布消息的android应用。我正在创建一个python程序来接收命令。但是,当我运行它时,我总是会遇到一个错误。 Traceback (most recent call la
当我尝试在虚拟环境中启动Jupyter笔记本时,出现以下错误-.gaierror:[Errno -2]名称或服务未知 虚拟环境-wget https://pypi.python.org/package
我正在尝试运行电子邮件收割机,当我在没有循环的情况下手动输入 url 时,我没有任何连接错误。 import re import requests import requests.exceptions
if data.find('!scan') != -1: nick = data.split('!')[ 0 ].replace(':','') targetip = socket.gethost
套接字模块中的一切都在工作,但是 socket.get host by name 给出了一个不希望的错误。 这是客户端代码: import socket s = socket.socket() s =
我需要创建简单的代码,将.csv文件上传到FTP服务器。代码如下。 import ftplib import os import sys sourceFilePath = '/home/user/di
socket.gaierror: [Errno 11004] getaddrinfo failed 我在一个简单的 ircbot 连接脚本中遇到了这个错误 import sys import sock
我是一名优秀的程序员,十分优秀!