0

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()
wjandrea
  • 28,235
  • 9
  • 60
  • 81
No-Question123
  • 61
  • 1
  • 1
  • 6
  • I'm not familiar with this library, so I'm not going to judge, but this question seems like basically, "Can someone help me?", which is [not an actual question as far as we're concerned on Stack Overflow](https://meta.stackoverflow.com/q/284236/4518341). Please try to ask a specific question. See [ask] for advice. Have you done any [debugging](/q/4929251/4518341)? Or how about adding some logging in the client or more logging in the server? – wjandrea Jul 01 '22 at 00:49
  • I did some debugging and poking around and I could not find the cause of this. vs code debugging turned up nothing. – No-Question123 Jul 02 '22 at 02:29

0 Answers0