Giter Club home page Giter Club logo

Comments (5)

 avatar commented on May 18, 2024

It blocks on DNS lookup, that's the only thing blocking. It's a valid issue for uSockets too, I haven't solved it yet. DNS lookup should happen in a thread pool.

from usockets.

Furujiang avatar Furujiang commented on May 18, 2024

Thank you for quick response, I changed my design to use uws in multithread because I found it don't work for creating multi group and make connect calls, only last connect call works.
It works well in each thread for 1 hub. Thank you again!

from usockets.

 avatar commented on May 18, 2024

You shouldn't hack with threading. If you require nonblocking DNS lookup then do that part yourself with a third party library and pass the IP to connect

from usockets.

Furujiang avatar Furujiang commented on May 18, 2024

the main problem for single thread is: below code only connect to url2 will work fine, no callback recieved from url1, is this a bug? thank you!

sample code:
hub_ = new Hub();
group1 = hub_->createGroup();
group1->onConnection([&](WebSocket *ws, HttpRequest req) {xxx});
group1->onError([&](void * self) {xxx};
group1->onDisconnection([&](WebSocket *ws, int code, char *data, size_t length) {xxx});
hub_->connect(url_1, nullptr, {}, 5000, group1);

group2 = hub_->createGroup();
group2->onConnection([&](WebSocket *ws, HttpRequest req) {xxx});
group2->onError([&](void * self) {xxx};
group2->onDisconnection([&](WebSocket *ws, int code, char *data, size_t length) {xxx});
hub_->connect(url_2, nullptr, {}, 5000, group2);
hub->run();

from usockets.

 avatar commented on May 18, 2024

Well since the first connection will block on DNS resolution the second connection might time out? Both should work.

from usockets.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.