1
I’m trying to connect to a server using python 3 with xml-rpc, but an error is appearing every time I try to connect: Connectionrefusederror: [Errno 111] Connection refused
This is my server code: (NOTE: I’m just running silly tests.)
from xmlrpc.server import SimpleXMLRPCServer
def void():
x = 1000
i = 0
while i < x:
i = i+1
return True
def main():
print("This is a server!")
server = SimpleXMLRPCServer(("localhost", 8080))
server.register_function(void)
server.serve_forever()
if __name__ == "__main__":
main()
That’s my client code:
import xmlrpc.client
import time
def main():
print("This is a client!")
client = xmlrpc.client.ServerProxy("http://localhost:8000")
client.void()
if __name__ == "__main__":
start = time.time()
main()
total_time = ("--- %s seconds ---" % (time.time() - start))
print("Time: " + str(total_time))
When I run xml-rpc on the same computer (different terminal) it works normal, but when I try on two different computers, it gives this error.
Juny, as the name suggests (Stackoverflow in Portuguese), the official language used here is Portuguese. So could you please translate your question? If you prefer, you can also ask the same question on Stackoverflow website in English.
– NoobSaibot
Wow, I totally confused hahaha. I already translated, thanks for the feedback!
– Juny
Have you tried instead of
http://localhost
you put the IP of the computer on the local network ? Ex:http://192.168.0.30:8000
?– NoobSaibot
Yeeeeah! It worked! Thanks @Noobsaibot
– Juny
@Noobsaibot better put the comment as an answer so that others who have the same problem find the solution by google (:
– Pedro von Hertwig Batista