by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    Chung
    @chungwong
    I confirm the error message is accessible as expected.
    Thanks you for your prompt commit.
    An Tao
    @an-tao
    Okay. I'll merge it tonight.
    Thanks.
    Eduardo Novaes Hering
    @enhering_gitlab
    Hi. Can somebody show me an example of a registerBeginningAdvice use?
    Eduardo Novaes Hering
    @enhering_gitlab
    I'm trying to use Drogon to receive a Json message and send it to a MQTT broker.
    I'm having difficulty in getting the MQTT connection library into the Drogon framework, so the message can be sent from inside an HTTPController instance.
    Is there a way to push a pointer to an extarnal class into the Drogon framework, so that class can be used from inside HTTPController?
    pmattione
    @pmattione

    Hello, I'm new to Drogon. I'm trying to create a websocket and connect on localhost, but it only connects ~10% of the time.
    In the browser I can connect to wss://echo.websocket.org/ 100% of the time, so I think something's wrong with my server config.
    Any ideas on what I can do to debug? Having problems with both ws: and wss: (using the server.pem in trantor/tests/). This happens in both Firefox and Chrome, haven't tested others.

    In Chrome the console gives me the errors:
    Unchecked runtime.lastError: The message port closed before a response was received.
    WebSocket connection to 'wss://localhost/' failed: Connection closed before receiving a handshake response.

    Thanks for the advice!

    An Tao
    @an-tao

    Is there a way to push a pointer to an extarnal class into the Drogon framework, so that class can be used from inside HTTPController?

    you could use a singlton class to access the extarnal class, such as a MQTTManager class.
    Or, use a pointer to an extarnal class to construct the controller object as following steps:

    class YourController : 
    public drogon::HttpController<YourController, false>//false flag disable creating the controller automatically by drogon.
    {
          YourController(ExternalClass *pointerToExternalClass);
          .....
    }

    in main function, create the controller and register it into the framework

       ....create the pointer to external class;
       auto controllerPtr=std::make_shared<YourController>(pointer);
       app().registerController(controllerPtr);
    An Tao
    @an-tao
    Hi. Can somebody show me an example of a registerBeginningAdvice use?
        app().registerBeginningAdvice(
            []() { LOG_DEBUG << "Event loop is running!"; });
    @pmattione Drogon closes the connection which is idle for a while,you could modify the idle_connection_timeout option in the configuration file to change the value of timeout. Or you could send ping messages from server side every short time to make the connection busy and ensure the status of the connection is ok. see #124
    An Tao
    @an-tao
    @pmattione you should create a WebSocketController to handle websockets. and use WS_PATH_ADD macro to define the path handled by the controller, in your case, the path is '/'
    pmattione
    @pmattione
    idle_connection_timeout is set to 60. If I don't set any methods does it default to all, or none?
    An Tao
    @an-tao
    All
    pmattione
    @pmattione

    OK, for my webpage I'm now using this: https://github.com/an-tao/drogon/blob/master/examples/simple_example_test/ws_test.html (except WS_PATH_ADD("/")), for my controller the example above (except using wss:://localhost/), and it works 100% of the time.

    But if I move the script to a separate connect.js file (and include it), wrap the contents in function init() {};, and add "window.addEventListener("load", init, false);" to the bottom, it fails with error message "Firefox can’t establish a connection to the server at wss://localhost/."

    Hmm, if I add "defer" to the <script src="connect.js" defer></script> it works 100% again. But then if I also link a css in the <head> it fails 100% again.
    Eduardo Novaes Hering
    @enhering_gitlab
    Thanks, @an-tao
    An Tao
    @an-tao
    @pmattione maybe the SSL connection is forbidden by browsers because of the self-assigned certifications.
    @enhering_gitlab you are welcome
    pmattione
    @pmattione
    Yeah, both Chrome and Firefox complained about it. I put "chrome://flags/#allow-insecure-localhost" in Chrome and told firefox to trust the cert. Switching to ws://localhost/ yields the same results: fine without the .css linked, fails with.
    I don't know if it matters, but I'm running with Visual Studio + WSL2, using WSL-GCC-Debug config.
    pmattione
    @pmattione
    For WSL2 using Ubuntu 20.04 LTS
    For the server
    An Tao
    @an-tao
    is the css file downloaded by browser normally? Ordinarily css should have nothing to do with websocket
    pmattione
    @pmattione

    index.html is just:
    <!DOCTYPE html>

    <link rel="stylesheet" href="/styles/Style_TablePage.css">

    <script src="/scripts/connect.js" defer></script>

    <pre id="log"></pre>

    css just changes the background color, connect script is what used to be in ws_test.html, wrapped in a function, and fires as above. No other controllers are mapped. int main() is just loading config.json and running.
    An Tao
    @an-tao
    Okay. would you mind to send me the connect.js and css file, I'll test it out in my local enviroment.
    Or you could create a github repo for the testing
    @kapilpipaliya What do u think about the issue?
    Eduardo Novaes Hering
    @enhering_gitlab
    @an-tao, the Drogon framework is very well built. Congratulations. Excellent work.
    An Tao
    @an-tao
    @enhering_gitlab Thanks for your encouragement.
    Eduardo Novaes Hering
    @enhering_gitlab
    @an-tao Can you give me a link on the motivation for having a mostly virtual header file and a separate implementation class? I've never seen this way of implementation before. I'd like to learn about that. (Not about virtual methods, those I know)
    An Tao
    @an-tao
    This is something like the well-known PIMPL idiom which is also used in Drogon.
    David Gray Wright
    @davidgwright
    Anyone recommend a front end frameworks to use with drogon - i'm thinking of using Angular. Preferably typescript based?
    kapilpipaliya
    @kapilpipaliya
    I have no problems with css
    @davidgwright use solidjs
    kapilpipaliya
    @kapilpipaliya
    An Tao
    @an-tao
    @kapilpipaliya , that issue had been fixed. thanks :)
    David Gray Wright
    @davidgwright
    @kapilpipaliya I shall look into solidjs - Thanks!
    David Gray Wright
    @davidgwright
    Any examples of modifying a drogon app to allow (CORS) cross -origin resource sharing?
    An Tao
    @an-tao
    1. Add Options method on routing path:
      METHOD_ADD(ClassName::MethodName,  Get, Options);
    David Gray Wright
    @davidgwright
    Thanks.
    Http 101 is it? I am new to this but not to C++.
    An Tao
    @an-tao
    101 is usually used for websocket.
    David Gray Wright
    @davidgwright
    Nah - that was a joke...I need an idiots guide to Http.
    Http 101 - is the course code for what class I need to go to.
    An Tao
    @an-tao
    ^.^
    An Tao
    @an-tao
    I think the access-control-allow-origin header is already added by Drogon when you add Options method on a path. so you don't need to added it manually.
    David Gray Wright
    @davidgwright
    I used the AOP approach and it's now working great!
    An Tao
    @an-tao
    Okay~
    Alexander
    @lambrou
    Hello. When using the default config.json file, I get the error:
    20200714 09:10:19.594066 UTC 15405 FATAL No such file or directory - TcpConnectionImpl.cc:113
    Aborted
    An Tao
    @an-tao
    This means the program can't find the certifications file for SSL. please comfirm the location of the server.pem file.