I've created a clientscript on my debian 11 vps and if i try to run the script i will get the BrokenPipeError: [Errno 32] Broken pipe.
I've noticed that my targetserver isn't receiving anything. The connection isn't even established i think. But if i ran the same script on my windows desktop it is working without any problems.
This is my code which runs on a windows machine but not on debian 11:
import socket
from time import sleep
class PySockAPIError(Exception): pass
dftHOSTPORT = ("IPADRESS", 30001)
dftAUTHPW = "STUPIDLONGPASSWORD"
dftCOMMAND = ("IS_SERVER_UP",)
class SOCKAPI:
def __init__(self, host = dftHOSTPORT, pwd = dftAUTHPW):
#con-data
self.HOSTPORT = host
self.AUTHPW = pwd
self.con = None
self.CreateCon()
def CreateCon(self):
try:
self.con = socket.socket(socket.AF_INET, socket.SOCK_STREAM, socket.SOL_TCP)
self.con.connect(self.HOSTPORT)
print("Connected to the Server!")
except socket.error:
print("TBD")
def CloseCon(self):
if self.con:
self.con.close()
print("Disconnected from the Server!")
def Send(self, cmd = dftCOMMAND):
try:
#send
CMDSEND = "\xFA%s\n" % cmd
CMDSEND = bytes(CMDSEND, "CP1252")
print(CMDSEND)
self.con.send(CMDSEND)
#receive
recv_data = self.con.recv(1024)
try:
print(recv_data.decode("CP1252"))
except:
pass
sleep(0.1)
except socket.error:
raise PySockAPIError("Socket failed, con-data maybe wrong (%s, %s, %s)"%(self.HOSTPORT[0], self.HOSTPORT[1], self.AUTHPW))
except socket.timeout:
print("TBD!")
if __name__ == "__main__":
sock = SOCKAPI()
msg = ""
while msg != "STOP":
msg = input("Enter a Command:")
sock.Send(msg)
sock.CloseCon()
Here is the output on the debain server
I've already tried to work with signal(SIGPIPE,SIG_IGN), but this just made my error disappear, but still the connection isn't registered on my targetserver. I don't know why the same script is running from windows but not from unix.
Thanks in advance