Skip to content
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

Closing UTP server takes a long time #40

Closed
CMCDragonkai opened this issue May 12, 2021 · 8 comments
Closed

Closing UTP server takes a long time #40

CMCDragonkai opened this issue May 12, 2021 · 8 comments

Comments

@CMCDragonkai
Copy link

After setting up a server and performing 1 successful connection with it, as soon as that connection is ended and destroyed, I try to close the UTP server, and it just hangs for about 20 to 25 seconds before it finishes.

I may have some UTP packets in the send buffer, but what are the expected amount of time taken for shutting down the UTP server since all connections have been destroyed.

@CMCDragonkai
Copy link
Author

CMCDragonkai commented May 12, 2021

And this isn't really mentioned in the docs. But if I close the server while there are on-going connections, does the server automatically trigger the destruction of those connections? Or is just going to hang forever?

If so, I will need to go to each connection and destroy them right?

@mafintosh
Copy link
Owner

Yea you need to destroy each socket yourself similarly to a tcp server in node

@CMCDragonkai
Copy link
Author

CMCDragonkai commented May 13, 2021 via email

@mafintosh
Copy link
Owner

mafintosh commented May 13, 2021 via email

@CMCDragonkai
Copy link
Author

Well it's in a particular test case in our project js-polykey. Specifically this test case: https://github.com/MatrixAI/js-polykey/blob/nodes-refactoring/tests/network/ForwardProxy.test.ts#L138

@CMCDragonkai
Copy link
Author

In my tests I'm creating 2 UTP sockets, one as the client socket and the other as the UTP server.

I've found that if I destroy all UTP connections, and then immediately close the client socket, this causes problems in closing the UTP server.

But if I wait 5 seconds before closing the client socket, the UTP server closes fine.

These tests are all running within 1 process.

Perhaps there's some issue with running multiple UTP sockets on the same process?

Or there is a problem if I were to close a UTP socket immediately after closing the the UTP connections?

@mafintosh
Copy link
Owner

PR a test case, and we'll take a look :)

@CMCDragonkai
Copy link
Author

I've currently resolved this by doing:

utpSocket.close()
utpSocket.unref()

That way I'm not waiting for the socket to finish.

Also prior to this, I have to close all connections and also wait 1 second for utp to flush any buffers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants