WebSocket-for-Python icon indicating copy to clipboard operation
WebSocket-for-Python copied to clipboard

[WinError 10061] No connection could be made because the target machine actively refused it

Open Frosty553 opened this issue 4 years ago • 2 comments

Hi, so I've been trying to code a file transfer program in python and it worked preety well on my pc (for now I only tested it with a txt file but I think it'll work with other files too), but the problem is when I tried running it on my brothers pc WinError 10061 popped up, I've done quite a bit of research before writing this and the common running the server before the client method doesn't work on my pc, I also tried turning off my antivirus thinking it blocked it but that didn't do anything either. I don't really know what to do anymore so I came looking for help here. I hope somebody can help me

Here is the server program code: import socket s = socket.socket() host = socket.gethostname() port = 8080 s.bind((host,port)) s.listen(1) print(host) print("Waitning for any incoming connections ...") conn, addr = s.accept() print(addr, "Has connected to the server")

filename = input(str("Please enter the filename of the file : ")) file = open(filename , 'rb') file_data = file.read(1024) conn.send(file_data) print("Data has been transmitted successfully")

And here is the client program code: import socket s = socket.socket() host = input(str("Please enter the host adress of the sender : ")) port = 8080 s.connect((host,port)) print("Connected ... ")

filename = input(str("Please enter a filename for the incoming file : ")) file = open(filename, 'wb') file_data = s.recv(1024) file.write(file_data) file.close() print("File has been received successfully")

Frosty553 avatar Jul 23 '21 10:07 Frosty553

Why would you use server-side websocket on windows?)

Mart-Bogdan avatar Sep 27 '21 18:09 Mart-Bogdan

I think issue is with windows firewall or program not being run as admin due to UAC. Try using another port, like 30155 or something other high enough (max port number is 65536)

does this error pops out on the server side of the app or on client-side?

Mart-Bogdan avatar Sep 27 '21 18:09 Mart-Bogdan