I built a voice call app and for some reason when I join the vc it just crashes the app. No errors, nothing. It appears that is it not connecting to the server even tho the connection details are correct but I think there is something else going on. Pls Help!
Here is the Server Code:
def on_server_stop():
log(consoleLog="Stopping Vc Server")
sys.exit()
host = '0.0.0.0'
port = 5000
server = socket.socket()
server.bind((host, port))
server.listen()
log(consoleLog='Voice call server started and online!')
clientsInVC = []
def handleVC(fromConnection):
log(consoleLog="User conected to VC server.")
while True:
try:
data = fromConnection.recv(4096)
for client in clientsInVC:
if client != fromConnection:
client.send(data)
except:
client.close()
clientsInVC.remove(conn)
while True:
conn, addr = server.accept()
clientsInVC.append(conn)
thread = threading.Thread(target=handleVC, args=(conn, ))
thread.start()
Here is the Client Code:
import pyaudio
import socket
import threading
def JOINVC():
print("started vc")
vcclient = socket.socket()
host = "127.0.0.1"
port = 5000
vcclient.connect((host, port))
p = pyaudio.PyAudio()
Format = pyaudio.paInt16
Chunks = 1024 * 4
Channels = 1
Rate = 44100
inputStream = p.open(format=Format, channels=Channels, rate=Rate, input=True, frames_per_buffer= Chunks)
outputStream = p.open(format=Format, channels=Channels, rate=Rate, output=True, frames_per_buffer= Chunks)
def sendData():
while True:
try:
data = inputStream
vcclient.send(data)
except:
break
inputStream.close()
def recive():
while True:
try:
data = inputStream.read(Chunks)
outputStream.write(data)
except:
break
outputStream.close()
sendThread = threading.Thread(target = sendData)
sendThread.start()
reciveThread = threading.Thread(target= recive)
reciveThread.start()