Skip to content

Socket.IO Asynchronous Read/Write (Not Working) #406

Open
@vladimirarevshatyan

Description

@vladimirarevshatyan

Good day. I am trying to implement the Asynchronous Read/Write within the Socket.IO.

The idea behind it is the Audio Calling. Let me describe in short what i am trying to do.

• The device is recording the Voice and on each recorded byte, the device sending that byte array to the server.

•Server is responsible to send the received byte back to the destination client.

• The Destination client is reading the byte array and playing it with the AudioTrack class of Android.

For this purpose i am using 2 different socket listeners and 1 single socket node server.

• "sendAudioBytes" event is used to emit the event when i need to send the captured audio data byte array to the server.

• "onAudioDataReceived" event is triggered whenever server has a new byte array to send to the client to play it on the client side.

The issue :
Everything is ultra-fine when i am using a one-direction communication,meaning the there are 2 devices, one is recording the audio and the 2nd one is playing the received audio.

The issue is coming whenever i want them both to record and play at the same time like 1st device recording audio,the 2nd device recording audio at the same time, the devices are playing audio at the same time as well.

Issue is that i receive the HUGE delays between audios the hugest as possible and every time the delay is different and NOT fixed.

By debugging i have the next appointment :

• Socket.IO keeps a buffer of received objects.
• Socket.IO gets the objects from buffer and trigger the appropriate callbacks for the client.
• Socket.IO not doing that Asynchronous and locks the another thread who is trying to read/write at the time when another thread is already reading/writing, which causes the huge delays.

My question is the next : How to enable the Asynchronous logic for such case?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions