gpt4 book ai didi

python - 什么可能导致 xmlrpclib.ResponseError : ResponseError()?

转载 作者:行者123 更新时间:2023-11-28 16:54:07 25 4
gpt4 key购买 nike

我正在试验 XML-RPC。

我有以下服务器脚本(Python):

from SimpleXMLRPCServer import SimpleXMLRPCServer

server = SimpleXMLRPCServer(('localhost', 9000))

def return_input(someinput):
return someinput

server.register_function(return_input)

try:
print 'ctrl-c to stop server'
server.serve_forever()
except KeyboardInterrupt:
print 'stopping'

和以下客户端脚本:

import xmlrpclib

server = xmlrpclib.ServerProxy('http://www.example.com/pathto/xmlrpcTester2.py')
print server.return_input('some input')

我已经在本地测试过了,效果很好。它所做的一切都是从客户端脚本中吐出输入,这是正确的。

但是,当我尝试在远程服务器上执行此操作时,出现以下错误:

Traceback (most recent call last):
File "client.py", line 4, in <module>
print server.return_input('some input')
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/xmlrpclib.py", line 1199, in __call__
return self.__send(self.__name, args)
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/xmlrpclib.py", line 1489, in __request
verbose=self.__verbose
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/xmlrpclib.py", line 1253, in request
return self._parse_response(h.getfile(), sock)
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/xmlrpclib.py", line 1392, in _parse_response
return u.close()
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/xmlrpclib.py", line 836, in close
raise ResponseError()
xmlrpclib.ResponseError: ResponseError()

有什么想法会导致这种情况吗?

更新:

verbose=True 时:

send: 'POST /pythonScripts/xmlrpcTester2.py HTTP/1.0\r\nHost:         www.example.com\r\nUser-Agent: xmlrpclib.py/1.0.1 (by www.pythonware.com)\r\nContent-    Type: text/xml\r\nContent-Length: 166\r\n\r\n'
send: "<?xml version='1.0'? >\n<methodCall>\n<methodName>return_input</methodName>\n<params>\n<param>\n<value><string>so me input</string></value>\n</param>\n</params>\n</methodCall>\n"
reply: 'HTTP/1.1 200 OK\r\n'
header: Date: Fri, 14 May 2010 20:52:25 GMT
header: Server: Apache/2.2.9 (Fedora)
header: Last-Modified: Fri, 14 May 2010 20:52:03 GMT
header: ETag: "7e206-13d-486940c17a2c0"
header: Accept-Ranges: bytes
header: Content-Length: 317
header: Connection: close
header: Content-Type: text/plain; charset=UTF-8
body: "from SimpleXMLRPCServer import SimpleXMLRPCServer\r\n\r\nserver = SimpleXMLRPCServer(('localhost', 8000))\r\n\r\ndef return_input(someinput):\r\n\treturn someinput\r\n\r\nserver.register_function(return_input)\r\n\r\ntry:\r\n print 'ctrl-c to stop server'\r\n server.serve_forever()\r\nexcept KeyboardInterrupt:\r\n print 'stopping'"
Traceback (most recent call last):
File "client.py", line 4, in <module>
print server.return_input('some input')
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/xmlrpclib.py", line 1199, in __call__
return self.__send(self.__name, args)
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/xmlrpclib.py", line 1489, in __request
verbose=self.__verbose
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/xmlrpclib.py", line 1253, in request
return self._parse_response(h.getfile(), sock)
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/xmlrpclib.py", line 1392, in _parse_response
return u.close()
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/xmlrpclib.py", line 836, in close
raise ResponseError()
xmlrpclib.ResponseError: ResponseError()

最佳答案

看起来远程机器上的那个端口上正在运行其他东西。并发回一个意想不到的答案。

我会检查服务器是否正确启动。然后检查防火墙设置中是否有任何可能影响事情的东西。

您还可以在客户端中打开详细标志,看看是否能说明问题。

编辑:

所以详细的输出清楚地表明了问题:您没有运行服务器,您是通过普通网络服务器共享它!

您需要在远程机器上运行服务器。

关于python - 什么可能导致 xmlrpclib.ResponseError : ResponseError()?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2837414/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com