-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UDP event listeners live forever #7
Comments
Possible resolution. I've yet to try this: call-api/pkg/ws_server/ws_server.go Line 170 in 630e5fa
Don't create another new Proxy in every incoming WS/WSS client request. Instead make it once at start time and attach the same proxy instances to all requests. Then we probably have to attach our internally generated cmd_id and match the responses back based on that cmd_id and once matched then deliver event/response back to the client.
|
@goharahmed UDP does not actually open a connection, it simply allocates a port and only uses it when sending a command. |
Yeah that could work. |
I am not saying no to your approach either, your approach is actually better. However, we still need to make sure that a proxy connection gets eventually closed at a certain point, correct? That's why probably the best approach would be a combination of the two. |
I totally agree and follow your directions. I need to revive my IDE and code repo to get the best understanding. |
Hi,
Probably my poor understanding of the code but it seems like the UDP event listener function are never ending loops. I've a test setup where initially sending a mi rpc request via call-api-client, call-api created a newer UDP local listener which never gets terminated.
Here is what I've understood is happening:
STEP1:
Create a NewProxy object every time a new wss/ws client sends request! (Can we not reuse older ones?)
NewProxy() has two major tasks.
1 - Establish connection to the opensips mi-datagram socket
2 - Create an event listener which can do subscriptions and filter on events
STEP2:
NewProxy() must connect to the opensips mi_datagram socket for sending commands, but to return a response/event it creates another UDP connection to the OpenSIPS mi_datagram socket.? Could we not have used the first connection's LocalAddr() instead.
EventHandler created another UDPConn to opensips mi_datagram socket and setup a goroutine waitForEvents()
STEP3:
waitForEvents() create a never expiring/ending for loop on the local side of the second mi_datagram UDPConn. Untill some error happens this doesn't break !
Questions:
Is this correct understanding?
Can we reuse the first established socket to mi_datagram for both sending commands and receiving replies for all incoming wss clients. Right now, every new WSS client sending command created a few sockets which live way longer than needed.
I'm implementing mi_http interface here, do I really need to have Events subscriptions or waitforEvents() functions?
The text was updated successfully, but these errors were encountered: